Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Graph plotting of red pixel vs number of images

1 visualización (últimos 30 días)
Gee Cheng Mun
Gee Cheng Mun el 13 de En. de 2016
Cerrada: Walter Roberson el 13 de En. de 2016
I would like to calculate the red pixel count for every image in this folder and then plot a graph of red pixel count vs the number of images. The red pixel count must correspond to the image no. This is my code.
%for loop
clc;
clear;
close all;
fontSize=10;
myFolder='G:\FYP2\Time Frames\Frame 24';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.png');
theFiles = dir(filePattern);
numberOfImages=length(theFiles);
red_counts = zeros(1, numberOfImages);
redCount=0;
for k=1:numberOfImages
fullFileName = fullfile(myFolder, theFiles(k).name);
thisImage=double(imread(fullFileName));
[rows, columns, numberOfColorBands] = size(thisImage);
redBand=thisImage(:,:,1);
%THRESHOLD LEVELS
redThresholdLow=215;
redThresholdHigh=255;
redMask=(redBand>=redThresholdLow) & (redBand<=redThresholdHigh);
%Count pixels
redCount=sum(redMask(:)>0);
red_counts(k)=redCount;
end
plot(red_counts, numberOfImages, '-r*');
set(gca, 'xTickLabel', 1:1:numberOfImages);
ylabel('Red pixel count');
xlabel('Number of images');

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by