how to find seed point and regions of interest in an image?

20 views (last 30 days)
In the seed.jpg image : first i need to find regions of interest on the basis of the brightest pixels having the maximal values because they represent the most significant regions in the image. Once the regions of interest are determined, the centroid of each region need to found. The resulting centroid pixel are the seeds for region growing algorithm.
The algorithm for region growing scans seed image S(x, y) to find a seed. When a seed is found, the region growing is performed from this point over the originalimage.jpg f(x, y). Region growing stops when a significant difference between the seed and the neighbour pixel is found.
I also see this code in a book but it don't accept my class of image. It needs to read an image with format such as .bmp, but I just have .fig (I cant save it with another format because of its bad quality). .fig image is better.
function [g,NR,SI,TI] = regiongrow( f,S,T )
%REGIONGROW Perform segmentation by region growing .
% [G,NR,SI,Tl)=REGIONGROW(F,s,T) .f is an image to be segmented.
%s can be an array(the same size as F )with a 1 at the coordinates of every seed point
% and Os elsewhere . S can also be a single seed value . Similarly ,
% T can be an array (the same size as F ) containing a threshold
% value for each pixel in F . T can also be a scalar , in which case
% it becomes a global threshold . All values in S and T must be in
% the range ( 0 , 1 )
%
% G is the result of region growing , with each region labeled by a
% different integer , NR is the number of regions , SI is the final
% seed image used by the algorithm , and TI is the image consisting
% of the pixels in F that satisfied the threshold test , but before
% they were processed for connectivity
f=tofloat(f) ;
% If s is a scalar , obtain the seed image .
if numel(S)==1
SI f==S ;
S1 = S ;
else
end
% S is an array . Eliminate duplicate , connected seed locations
% to reduce the number of loop executions in the following
% sections of code .
SI=bwmorph( S ,'shrink' ,Inf) ;
S1 = f(SI) ; % Array of seed value s .
TI=false(size(f)) ;
for K = 1 : length(S1)
seedvalue=S1(K);
end
S = abs(f-seedvalue)<=T; % Re - use variable S .
TI = TIIS;
% Use function imreconstruct with SI as the marker image to
% obtain the regions corresponding to each seed in S . Function
% bwlabel as signs a different integer to each connected region .
[ g , NR ] = bwlabel( imreconstruct(SI,TI)) ;
end
  2 Comments
Image Analyst
Image Analyst on 1 Jan 2016
I'll fix the formatting in your post this time, but please read http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup for next time. Also using Firefox may be useful since it has a built-in spelling checker.
mari ahmad
mari ahmad on 1 Jan 2016
thank you Image Analyst can you help me about my question

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 2 Jan 2016
Theshhold your image, then regionprops() and request Centroids. bwdist() to find the closest pixel that is actually in the image. Caution: a centroid is not necessarily in an object, so you might even want to proceed region by region to be sure you are getting a point inside the region.
If you get too many regions then threshold again with a higher threshold.
  1 Comment
mari ahmad
mari ahmad on 3 Jan 2016
Dear Walter Robercon thank you alot. i find the center object. now i dont know how to put them in a matrix i meen i want put them in my original image and put them 1 other pixel 0.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 1 Jan 2016
Like I said in your earlier post with the same question: "In the meantime, look at grayconnected() and imerode() and let us know if either of those can help you." and Walter suggested bwmorph(), which is looks like you're trying. grayconnected() is the build-in regiongrowing function and that's what I'd try.
Anyway, you don't say what kind of output you want. Do you want an image with uniform gray level regions? Or something else?
First I'd try to figure out why you're only able to save .fig files and not regular files like PNG, TIF, or BMP with imwrite(). If you have the Image Processing Toolbox you should be able to save standard format images instead of .fig files. Where did you get the original images?
Anyway, to find seeds, you can use find() to find the row and column of the last remaining regions. Keep track of what pixels you've logged to a "used" image and then mask that against your original gray scale image
maxGrayLevel = mean2(grayImage .* uint8(~usedPixels));
[row, column] = find(grayImage == maxGrayLevel, 1, 'first');
row, column specifies where the next brightest unused pixel lives.
Again, tell us exactly what form of output you would like from this.
  3 Comments
Image Analyst
Image Analyst on 3 Jan 2016
Let's say that you're examining a pixel at (100,100) and that you find the neighbor pixel (100, 101) is also connected because it's a similar gray level or meets your criteria for being in the same region. So now you leave (100,100) and go to (100,101) to examine it's neighbors. Well (100,100) is a neighbor of that pixel that meets the "same region" criteria. But you don't want to go back to (100,100) and examine that pixel again -- you already did that! So you have to have binary (logical) image that says which pixels you've visited/examined already so that when you move on to examine new pixels you don't visit pixels that you've already visited.
alreadyVisited(row, col) = true;
You only want to visit pixels if alreadyVisited(row, col) is false.
if ~alreadyVisited(nextRow, nextCol)
% We have not been at this pixel yet, so we can go there.
Otherwise you'll just hop back and forth between two pixels, or a set of pixels. Does that make sense?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!