Borrar filtros
Borrar filtros

Is my bar graph accurately graphing what I ask?

1 visualización (últimos 30 días)
Neo
Neo el 2 de Feb. de 2023
Comentada: Image Analyst el 3 de Feb. de 2023
i have an image which i have divided into 12 regions. I have made a code that I think counts the number of green dots in that image and plots them in a bar graph as function of the region in the image. is the code doing what i expect it to do? please correct or confirm.
First, the code converts the image (premask) into a gray image then applies a mask (screenshot). now that the mask is applied i want to count those specks as a function of their region because i want to see how the specks fluctate by number across the image in its differnt regions.
% count the graylevel specks and plot as a function of the region number (the once green specks).
greenspots = (g<255);
numberofgreenspots = numel(grayImage);
[pixelCounts, grayLevels] = imhist(grayImage);
%meanGL(k) = mean(grayImage(masksinusoid));
figure
bar(numberofgreenspots, 1:length(endingColumns));
grid on;
title('counting')
xlabel('green speck #')
ylabel('region #')

Respuesta aceptada

Image Analyst
Image Analyst el 3 de Feb. de 2023
No, you'd need to do this
% count the graylevel specks and plot as a function of the region number (the once green specks).
for k = 1 : whatever
greenSpotMask = g < 255; % g is the image of just this strip only.
% Count pixels.
areaOfGreenSpots(k) = nnz(greenSpotMask)
% Count number of contiguous regions.
[~, numberOfGreenSpots(k)] = bwlabel(greenSpotMask);
% Display histogram of strip.
[pixelCounts, grayLevels] = imhist(g);
%meanGL(k) = mean(grayImage(masksinusoid));
end
figure
bar(numberOfGreenSpots);
grid on;
title('Counting of Green Spots per Strip Region')
xlabel('Region #')
ylabel('Number of green spots in the region')
  9 comentarios
Neo
Neo el 3 de Feb. de 2023
So i can understand your though process better, why did you plot them seperatley?
Image Analyst
Image Analyst el 3 de Feb. de 2023
They represent totally different things and have different ranges. The number of pixels might be in the hundreds of thousands and the number might be a few dozen or hundred. You'd need at least 2 y axes, using yyaxis(), to plot them on the same plot. Like I said, the number of spots, like what you names the variable at the beginning, is most likely not what you want. You probably want the number of pixels (which is the area).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Deep Learning for Image Processing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by