Borrar filtros
Borrar filtros

Masking out black area from the created binary mask

2 visualizaciones (últimos 30 días)
Dhrupad Prajapati
Dhrupad Prajapati el 10 de Mayo de 2022
Comentada: Image Analyst el 19 de Oct. de 2023
Hi all,
I am new to Image processing and I am doing the image processing to mask out the ROI.
From the result image, As I already defined the ROI (from this ref: https://in.mathworks.com/help/images/detecting-a-cell-using-image-segmentation.html?s_tid=srchtitle_cell%20detection_2), I want to mask out again the middel part of the image that is black and gray area. Is it possible to segment that black area from masked out image? I want to convert that maskedout image into again binary image and then want to count the black pixels and white pixels inside the mask.
I = imread('2022-05-10_11h25_21.png');
imshow(I)
I masked out the original image with the binary mask and then converted it into binary image. But here what I want to do is to detect only black area which is inside the white shape. Later I want to fill it up that black part to get rid of those small white dots. see the sample below.
I2 = imread('2022-05-10_11h36_40.png');
imshow(I2)
Please help me which method should I follow to get the results? Or is it possible to solve such problems? Thank you in advance.
  2 comentarios
Dhrupad Prajapati
Dhrupad Prajapati el 10 de Mayo de 2022
@Image Analyst Please help me out with this. Thank you in advance.
Image Analyst
Image Analyst el 19 de Oct. de 2023
Not sure how I missed this a year and a half ago. Not sure what you want but it sounds like you wanted the dark gray rectangle with the white circle to be your ROI. Then you wanted to binarize that to turn it into black and white and count the number of black and white pixels. Then you wanted to make the small white blobs inside the gray rectangle (not including the large white circle) into black, and again count the number of clack and white pixels. Is that what you wanted to do? If so, could you attach the original (not screenshot) gray scale image if it is still a need for you?

Iniciar sesión para comentar.

Respuestas (1)

Githin George
Githin George el 19 de Oct. de 2023
Hello,
I understand you are trying to binarize the left image from 2nd attachment and fill the small white dots inside the right image, with black color.
The following code can be used to achieve the above requirement:
[X,map] = imread('yourImage.png');
% Make your 2D grayscale image into a binary image
X = X(:,:,1);
X = imbinarize(X);
imshow(X)
% Fill the small 'white' holes with less than 400 pixel connections
Ifill = bwareaopen(X, 400);
figure
montage({X,Ifill})
The “imbinarize” function converts your Grayscale image into a Binary Image and “bwareaopen” fills the white dots inside the the image. Please, adjust parameters for both these functions to obtain the desired result.
Kindly refer to the following documentation links for the above-mentioned functions below,
Below is the output obtained using the above code for reference,
I hope this helps.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by