MATLAB Answers

How to select the desired object in a certain region in an image?

4 views (last 30 days)
Wenying Zhang
Wenying Zhang on 3 Jul 2020
Commented: Image Analyst on 4 Jul 2020
Hi all,
I have plenty images to process and calculate the frost area/ volume on a heat exchanger. First, I have some local images and I used matlab to crop them to a certain size that I have only two fins. Then, I want to calculte the triangle area between fins and tubes because I want to calculate the frost area = the difference of this trangle area between images. Thanks to this forum, I've been able to crop the images, deblur the images, covert them to binary image, find the closed area/ objects in the image, label the objects and calculate the areas.
However, there are about 30 objects in each image and I just need two of them in the central part (The green and yellow triangles, for example). How can I select and output the information, like shape, areas, centroids of those two objects? Can I achieve this based on the boundary limitation of the initial triangle region? Also, How can I plot the difference of image 1 and 2, so that I can show the frost thickness?
Thank you in advance!

  0 Comments

Sign in to comment.

Answers (2)

Wenying Zhang
Wenying Zhang on 3 Jul 2020
I suppose "polygon" and "inpolygon" can be used to achieve the goal.

  3 Comments

Wenying Zhang
Wenying Zhang on 4 Jul 2020
Now I've been able to use those two functions to select the centroids I want; however, it's not that accurate (12 out of 20 are successful). Because I used one single polygon for both of the triangles, and there were a few objects/ noises on the boundaries of both of them. I'm going to try with two smaller polygons.
Wenying Zhang
Wenying Zhang on 4 Jul 2020
For example, I can find two desired centroids in the 1st image and imwrite the information I need. However, I have noise in the 2nd image and I have to manually choose the info I want.
Wenying Zhang
Wenying Zhang on 4 Jul 2020
I found "bwareaopen" can be used for removing small noise. This might be helpful for the beginning, when the desired triangle areas are larger. However, in the later process, those areas can become much smaller, close to the noise...

Sign in to comment.


Image Analyst
Image Analyst on 4 Jul 2020
Just check the area and centroid and throw out those that aren't close enough to the middle and large enough
labeledImage = bwlabel(binaryImage);
props = regionprops(labeledImage, 'Area', 'Centroid');
allAreas = [props.Area];
xy = vertcat(props.Centroid);
y = xy(:, 2);
[rows, columns] = size(binaryImage);
keepers = (area >= minimumAcceptableSize) & (abs(y - rows/2) > rows/8)) % Find big blobs in the middle quarter of the image.
% Get new binary image
binaryImage = ismember(labeledImage, find(keepers));
% Get new properties
props = regionprops(binaryImage, 'Area')

  6 Comments

Show 3 older comments
Wenying Zhang
Wenying Zhang on 4 Jul 2020
Actually, there is an issue I've noticed when I process my images: the edge detection became less accurate when the frost accumulated. The boundry of the frost and the light were not distiguished by the program. The images are attached here. Any suggestion will be appreciated!
BW = bwareaopen(imbinarize(I),40); % removes all objects smaller than 40 pixels
[B,L] = bwboundaries(BW,'noholes');
imshow(label2rgb(L, @jet, [.5 .5 .5]))
Wenying Zhang
Wenying Zhang on 4 Jul 2020
As I said, at the beginning, the gap between the fin and tubes are large and there is no frost. The noise are all smaller and far away from the middle. However, as what I attached, the gap between the frost become smaller and it also moves away from the middle. Now, it's the tricky part to divide the noise and the desired objects. For your question, I know it's noise because it' clear in the original images. I can show you a series of the images as time goes by. The latter part is really diffcult to calculate.
Image Analyst
Image Analyst on 4 Jul 2020
I don't see a problem. When the frost grows and the ice blobs merge, of course they will eventually merge into a giant blob, and your measurements will reflect that. Why not just subtract the time zero image from all the others to find out what pixels are now icy? The total area of all ice blobs would be a good metric for how much frost accumulation there is. Why do you need anything beyond that?

Sign in to comment.

Products


Release

R2019a

Translated by