Hello, can anyone help me how to find the only whitepixels that mushrooms occupied in given image??

1 visualización (últimos 30 días)
My Code:
clc;
clear all;
close all;
I=imread('50pic1.jpeg');
figure;
imshow(I)
g = rgb2gray(I);
figure;
imshow(g)
impixelinfo
BW=imbinarize(g);
figure;
imshow(BW)
noofWhitepixels=sum(BW(:))
disp(noofWhitepixels)
By using this code i am getting All no of whitepixels in an image but i only want whitepixels of mushrooms that occupied in an image

Respuesta aceptada

Pratyush Roy
Pratyush Roy el 30 de Sept. de 2021
Hi Anuradha,
As per my understanding you want to find onl the white pixels in the image of the mushroom.
As a workaround, you can try using the imerode function to remove small white patches after binarizing the image with imbinarize. The following code snippet demonstrates the use of bith these functions:
im1 = imread('mushroom.jpeg');
gray_image = rgb2gray(im1);
bw_image = imbinarize(gray_image);
se = strel('line',11,90);
erodedBW = imerode(bw_image,se);
imshow(erodedBW)
Hope this helps!

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by