I want to read images from a gallery contain 20 color images and then convert these to gray scale images and finding histogram for each,how can I do it? making index for every image!!!

2 Ansichten (letzte 30 Tage)
clc
for i=1:20
g(i)=imread(D:\Master\Research\Practical-Matlab\1\m.jpg');%gallery images
f(i)=rgb2gray(g(i));
end

Antworten (1)

Joseph Cheng
Joseph Cheng am 16 Nov. 2015
you'll have to do something like this:
yourgalleryfolder = 'D:\Master\Research\Practical-Matlab\1\';
imagefiles = dir(fullfile(yourgalleryfolder,'*.jpg'));
Images = struct('data',[],'histogram',[]);
for ind = 1:numell(imagefiles)
Images(ind).data = imread(fullfile(yourgalleryfolder,imagefiles(ind).name));
Images(ind).histogram = hist(Images(ind).data);
end
  2 Kommentare
Batool Engineer
Batool Engineer am 17 Nov. 2015
thank you, but here I have an error, appear down: Undefined function 'numell' for input arguments of type 'struct'.
Error in ppp1 (line 6) for ind = 1:numell(imagefiles)
Stephen23
Stephen23 am 17 Nov. 2015
The correct function name is numel, exactly as any internet search engine would have told you.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by