how to use image in exterma mfile?

i download an mfile named exterma from here,which finds exterma points in an image, http://www.mathworks.com/matlabcentral/fileexchange/12275-extrema-m--extrema2-m/content/extrema/extrema.m and http://www.mathworks.com/matlabcentral/fileexchange/12275-extrema-m--extrema2-m/content/extrema/extrema2.m when I put my image address instead of xy,it gives me the error:(Undefined function 'extrema' for input arguments of type 'uint8'.) I don't know how to locate my image in this mfile,i just write these 2 lines: m=imread('image adress.jpg'); xy=rgb2gray(m); I also find 2 other mfiles here which detect exrema points in an image,but they only give me hundreds of 0 and 1,i want to detect exterma point in my image,show an image for result. http://www.mathworks.com/matlabcentral/fileexchange/45338-findextrema/content/findExtrema.m
http://www.mathworks.com/matlabcentral/fileexchange/41955-find-image-extrema isn't it better to use hit or miss for detecting exterma points?i want to detect top left,right top.... and for each one change the proper strel.?

 Accepted Answer

Ok, I'll translate the problems:
Undefined function 'extrema' for input arguments of type 'uint8'.
That means that the extrema file is not visible to the matlab path. The command "which extrema.m" should result in a path being printed if it is on the path.
In terms of finding extrema on an image, you need to be very clear with what you mean.
Are you looking for the list of pixels which are higher than all of their neighbours, on a pixel to pixel basis, or are you looking for an area of bright (or dark) pixels (hotspots)?
If you need hotspots, this is something like what you want to do... If you take your image "im" and do this:
im = im - min(im(:));
im = im / max(im(:));
You'll have your image scaled between 0 and 1. You can then find hot spots/regions with this (modify the > 0.9 to suit)
hotspots = im > 0.9;
imagesc(hotspots)
figure
imagesc(hotspots .* im)

7 Comments

sara
sara on 18 Sep 2014
Edited: Image Analyst on 18 Sep 2014
Thank you for your answer. I wanted to find corners like this image:
Ok, so I've given you the first half then, and this is the second half:
labelled = bwlabel(hotspots);
stats = regionprops(labelled,'extrema');
iain it give me error.i used this code:
i=imread('..'); m=rgb2gray(i); m = m - min(m(:)); m = m / max(m(:)); hotspots = m > 0.9; imagesc(hotspots) figure imagesc(hotspots .* m) labelled = bwlabel(hotspots); stats = regionprops(labelled,'extrema');
it gives me this error:(Error using .* Integers can only be combined with integers of the same class, or scalar doubles)
Nope, won't work. Bytes have to multiply by bytes (uint8) not any other class. Plus dividing by the max may give you all zeros if it stays integer. Try this:
grayImage = imread('..');
m=rgb2gray(grayImage);
m = m - min(m(:));
hotspots = m > 0.9;
imagesc(hotspots)
figure
% Method 1: convert to double
m = double(m) / max(m(:));
maskedImage = hotspots .* m; % No need to cast because m is double now.
% Method 2, leave as integer, but will be all zeros or 1's.
maskedImage = m / max(m(:)); % Just 0 or 1s
maskedImage(~hotspots) = 0;
% Method 3, leave as integer, but will be all zeros or 1's.
maskedImage = m / max(m(:)); % Just 0 or 1s
maskedImage = maskedImage .* uint8(hotspots); % Cast logical to uint8
imshow(maskedImage, []);
labelled = bwlabel(hotspots);
stats = regionprops(labelled,'extrema');
thank you for your answer,it gives me 2 images,the second one Is the original image,and the first one is the origina image plus some shadows around the border,i want to detect extrema points like corner detection,to show only extrema corners in the image,,can I handle it through corner functions?thanx
You can use bwboundaries() on the mask image and then use a for loop to find the most distant points. See attached example. (Wow, I'm just posting tons of demos today. But only a fraction of all of them I have, which is about 150 of them.)
thank you so much,i should read it,.thanx

Sign in to comment.

More Answers (0)

Tags

Asked:

on 18 Sep 2014

Commented:

on 20 Sep 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!