Magnify Surface Blobs and Paint Them

1 次查看(过去 30 天)
Hi,
I am working on a image processing issue where I obtained certain amount of surface features. After I found surface features as blobs, I want to magnify them at the same center they are by a certain ratio. In the end, I will paint the original blob to a color and the area difference between the magnified version and the original to another. For certain ones they may collide when magnified but I will keep the original blob on the surface of the final image.
Is there a way to do this? Probably it should be related to boundaries but I couldn't manage to do it with bwboundaries. I am attaching an example surface for this purpose.
Thanks in advance.
  2 个评论
Image Analyst
Image Analyst 2023-9-15
So you want the original blob to be one color, and the enlarged annular region around it to be a different color?
I'm not sure if you want to
  1. find the outline/boundary of each segmented blob, then enlarge it and draw the enlarged outline over the image, or
  2. crop out a blob and enlarge it and paste it on top of the image.
Which is it? 1 or 2 or something else? In the meantime I'm attaching copy and paste demos. If it's 2 the final image will of course depend on the order that you do the pasting.
Bugrahan Guner
Bugrahan Guner 2023-9-15
Hi, It is actually the first one. As long as I have the original and enlarged outline/boundary over the original image and be able to paint them (before or after) I export the file as an image, that will do. Main goal is to come up with an area ratio so I eventually plan to do that thorugh colored pixel information.
In the meantime for the above case, I was trying to do it by finding the centers of the blobs and magnify the distance between the center and the outline pixels with the desired amount but if there is a neater way to do it, I would love to try it.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2023-9-15
Well there are two ways to draw outlines of the original and enlarged region.
  1. Use bwboundaries to get the outline of the segmented blobs, then use regionprops to get the centers, then multiply the distances from the boundaries to the centroid by some scaling factor, or (easier)
  2. Get original boundaries, then call bwmorph with the 'thicken' option, then get enlarged boundaries with bwboundaries
Which do you prefer?
Either provide the original image and your segmentation code, or upload your segmented binary image.
Boundary finding and drawing code snippet:
% Plot the borders of all the blobs in the overlay above the original grayscale image
% using the coordinates returned by bwboundaries().
% bwboundaries() returns a cell array, where each cell contains the row/column coordinates for an object in the image.
imshow(originalImage); % Optional : show the original image again. Or you can leave the binary image showing if you want.
% Here is where we actually get the boundaries for each blob.
boundaries = bwboundaries(mask);
% boundaries is a cell array - one cell for each blob.
% In each cell is an N-by-2 list of coordinates in a (row, column) format. Note: NOT (x,y).
% Column 1 is rows, or y. Column 2 is columns, or x.
numberOfBoundaries = size(boundaries, 1); % Count the boundaries so we can use it in our for loop
% Here is where we actually plot the boundaries of each blob in the overlay.
hold on; % Don't let boundaries blow away the displayed image.
for k = 1 : numberOfBoundaries
thisBoundary = boundaries{k}; % Get boundary for this specific blob.
x = thisBoundary(:,2); % Column 2 is the columns, which is x.
y = thisBoundary(:,1); % Column 1 is the rows, which is y.
plot(x, y, 'r-', 'LineWidth', 2); % Plot boundary in red.
end
hold off;
caption = sprintf('%d Outlines, from bwboundaries()', numberOfBoundaries);
fontSize = 15;
title(caption, 'FontSize', fontSize);
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
  1 个评论
Bugrahan Guner
Bugrahan Guner 2023-9-15
编辑:Bugrahan Guner 2023-9-15
Hi, I am attaching the segmented image. So the issue for the first method for me was the concave and convex shapes of the boundaries obtained and the blobs neighbouring the corners of the image. I may use a guidance there on how to proceed with that idea. For the border thickening, I am not sure how to come up with a proper ratio to be honest since the original blob and the larger one should have a specific ratio between them.(in the end if the area of inner one is 9x for the larger ones 16x so the area between two blobs is 7x after enlarging and plotting two boundaries.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by