Matching original coloured images to their black and white version to remove the black parts and keep the white parts for multiple images.

1 次查看(过去 30 天)
For example, this would be the original input image
And this would be the black and white output image that I would like to match it to.
Once that is done, id like to segment the image where it gets rid of the black and only keeps the white. At the end, it should output only the bit of the original image that matched to the white for further analysis of the cells without the background(black parts). Id also like to output these images into their own file that i can access on my desktop to look at.

采纳的回答

Image Analyst
Image Analyst 2020-10-11
Not exactly sure what you want, and not sure if what you think you want is really what you need. If you have the mask, then regionprops() automatically ignores the black pixels while making measurements. So matching, segmenting, and extracting (as you asked for) are NOT needed.
You cannot get rid of black pixels because an image has to remain rectangular. However, if you want to extract only the white pixels into a list (a 1-D vector) you can pass the mask in to the gray scale image as an index:
selectedPixelValues = grayImage(mask); % Vector of only gray levels within mask
If you want a masked image where the white parts show up in their original gray scale and the background is black, you can create a masked image like this:
% Mask the image using bsxfun() function to multiply the mask by each channel individually. Works for gray scale as well as RGB Color images.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask, 'like', rgbImage));
If you want to crop off some of the black, to make a smaller image, you could, but it's not really necessary.
[r, c] = find(mask);
croppedImage = grayImage(min(r):max(r), min(c):max(c), :);
  4 个评论
Image Analyst
Image Analyst 2020-10-13
Rana, what is the remaining problem? You haven't accepted the answer yet, so why are you not able to solve this with my suggestions? What do we need to do to get it working for you? What measurements do you want to make (area, brightness, etc.)? Can you attach your code where you created the binary image?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by