jaff12
jaff12

Reputation: 11

Using imtophat in MATLAB

I'm trying to do top hat filtering in MATLAB. The imtophat function looks promising, but I have no idea how to use it. I don't have a lot of work with MATLAB before. I am trying to look find basically small spots several pixels wide that are local maxima in my 2 dimensional array.

Upvotes: 1

Views: 3387

Answers (3)

Jacob
Jacob

Reputation: 34621

The documentation on imtophat has an example .. did you try it? The following images are from the MATLAB documentation.

Code

I = imread('rice.png');
imshow(I)
se = strel('disk',12);
J = imtophat(I,se);
figure, imshow(J,[])

Original

input rice image

(image source: mathworks.com)

Top Hat with a disk structuring element

rice image with tophat filter applied, and contrast-stretched

(image source: mathworks.com)

Upvotes: 1

Roman
Roman

Reputation: 11

tophat is basically an "opening" procedure followed by a subtraction of the result from the original image. the best and most helpful explanation of opening I've found here:
http://homepages.inf.ed.ac.uk/rbf/HIPR2/morops.htm

"The effect of opening can be quite easily visualized. Imagine taking the structuring element and sliding it around inside each foreground region, without changing its orientation. All pixels which can be covered by the structuring element with the structuring element being entirely within the foreground region will be preserved. However, all foreground pixels which cannot be reached by the structuring element without parts of it moving out of the foreground region will be eroded away."

Upvotes: 1

yuk
yuk

Reputation: 19880

I think you have more problem undertanding how to use STREL, than IMTOPHAT. The later can be described as simple threshold but per structural element, not the whole image.

Here is another good examples of using STREL and IMTOPHAT: http://www.mathworks.com/matlabcentral/fx_files/2573/1/content/html/R14_MicroarrayImage_CaseStudy.html

This series of posts on Steve Eddins blog might be useful for you: http://blogs.mathworks.com/steve/category/dilation-algorithms/

Upvotes: 1

Related Questions