Profile of image in grey scales

Good afternoon, I would really appreciate if you could help me with a particular issue related with image analysis. I have a set of images in grey scales. From the images I require to get an edge of the profile. I have tried different commands to get the profile or edge of the flow. Using canny and imerode and imdilate commands the best that I got is as shown in the image. However I need to get an edge of the whole profile as with the red line in image attached.
Any suggestions
Thanks a lot in advance
Best regards,
The script for this part is:
threshold = graythresh(MyImage); bw = im2bw(MyImage,threshold); se = strel('disk',2); bw = imclose(bw,se); BWsdil = imdilate(bw, se); BWsdil = bwperim(BWsdil); BWoutline=edge(BWsdil, 'canny',0,1);
Segout = MyImage; Segout(BWoutline) = 255;
figure(1), imshow(Segout)

Answers (2)

You don't need edge detection at all. Just threshold and go along column by column using find() to find the top row. Something like (untested)
binaryImage = grayImage > 50; % Adjust the value to eliminate dark background.
binaryImage = bwareaopen(binaryImage, 200); % Get rid of blobs smaller than 200
imshow(binaryImage);
[rows columns] = size(binaryImage);
topRows = rows * ones(rows, columns, 'int32'); % Initialize
for col = 1 : columns
topRows(col) = find(binaryImage(:, col), 1, 'first');
end

4 Comments

Image Analyst
Image Analyst on 23 Apr 2013
Edited: Image Analyst on 23 Apr 2013
Referring to your "Answer" below (which should have been a comment here)...
Why do you have 3 blobs? Aren't you after the top most surface? If you want them as three separate blobs, then just use
boundaries = bwboundaries(binaryImage);
And you should not lose all your data by getting rid of blobs smaller than 200 pixels.
Please post the original grayscale image with no canny and no red outlines.
Sorry, I didn't know where to write my answer to you. Thanks for letting me know. My intention is to get the whole flow with a perfect BLACK background. What I was trying to get is the profile or edge of the whole profile. With that edge I can apply that everything outside the flow to be black (i.e. '0') and everything inside the flow to keep the original image. In this way, I get a perfect black background and I dont loose any information inside the flow. Some of the balls go faster and they separate from the whole flow. They are very important too. However, I think blobs smaller than 200 pixels should be fine. I have tried using boundaries = bwboundaries(binaryImage); However I get similar results than with my scripts. I dont get a outline line as I need it. Thanks a lot for your support. I really appreciate it.
<<i-imgbox-com-adiQ0Qj8-jpg.n>>

Sign in to comment.

600Seat
600Seat on 23 Apr 2013
Thanks for your reply. I have tried your suggestion. However I am not getting an edge similar to the red line edge as showed in my previous image.
I have tried using different values to eliminate dark background. Since with 50, I eliminate the background and mainly all the data that I need.
The second command to get rid ob blobs smaller than 200, I cannot used since again I loose all my data.
I am looking for some command to join the gaps between the white groups. It should be something as a curve with best fit. But I am not sure how to do it.
It could be that I am trying to do something that it is not possible... I dont know.
I would appreciate it if you could help me with this. Thanks

Asked:

on 23 Apr 2013

Community Treasure Hunt

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

Start Hunting!