フィルターのクリア

How to save Histogram of Multiple Images

3 ビュー (過去 30 日間)
Diah Junaidi
Diah Junaidi 2019 年 7 月 31 日
コメント済み: KALYAN ACHARJYA 2019 年 7 月 31 日
I used this code but the results is unsatisfied :( please help me :(
% Specify the folder where the files live.
myFolder = 'D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\imagesss';
% Check to make sure that folder actually exists. Warn user if it doesn't.
% if ~isfolder(myFolder)
% errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
% uiwait(warndlg(errorMessage));
% return;
% end
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.JPG'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
methodFile = imread(fullFileName);
grayscale = rgb2gray(methodFile);
histogram = imhist(grayscale);%using this for histogram
currentImageArray = histogram;
currentImage{k}=currentImageArray;
for i = 1 : 1
outputFolder = 'D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\Hasil Histogram Dataset\1';
outputFileName = fullfile(outputFolder, sprintf('Hasil Citra Ground Truth_%d_%d.jpg', k, i));
imwrite(currentImage{k}, outputFileName);
end
end
here the results:
Hasil Citra Ground Truth_1_1.jpg
  1 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 7 月 31 日
編集済み: KALYAN ACHARJYA 2019 年 7 月 31 日
"results is unsatisfied' means?
You want to save histogram plots ??

サインインしてコメントする。

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 7 月 31 日
編集済み: KALYAN ACHARJYA 2019 年 7 月 31 日
Images=dir('D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\imagesss*.jpg'); %Database Image folder
%......................[] ^ IS this OK?
outDirectory='D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\Hasil Histogram Dataset\hist_data\'; % To save histograms
%......................^ set valid path "hist_data" folder will create by Matlab itself
mkdir(outDirectory);
for i=1:length(Images)
ImgName=strcat('D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\imagesss\',Images(i).name);
RGBImage=imread(ImgName);
grayImage=rgb2gray(RGBImage);
imhist(grayImage);
imwrite(gcf,strcat(outDirectory,Images(i).name));
end
  5 件のコメント
Diah Junaidi
Diah Junaidi 2019 年 7 月 31 日
I got this error:
Error using imwrite (line 420)
Expected DATA to be one of these types:
numeric, logical
Instead its type was matlab.ui.Figure.
Error in cobaHistogramDataset (line 11)
imwrite(gcf,strcat(outDirectory,Images(i).name));
by using this code:
Images=dir('D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\imagesss\'); %Database Image folder
%......................[] ^ IS this OK?
outDirectory='D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\Hasil Histogram Dataset\1'; % To save histograms
%......................^ set valid path "hist_data" folder will create by Matlab itself
% mkdir(outDirectory);
for i=1:length(Images)
ImgName=strcat('D:\DIAH\[MATLAB]cv1-fingerspelling-recognition-master\cv1-fingerspelling-recognition-master\imagesss\set1_a.jpg',Images(i).name);
RGBImage=imread(ImgName);
grayImage=rgb2gray(RGBImage);
imhist(grayImage);
imwrite(gcf,strcat(outDirectory,Images(i).name));
end
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 7 月 31 日
why should we use .jpg if we wanna perform all images at once from the database folder?
Its depneds on the image format you have (jpg,png etc). Here one by one image call is done, get the histogram and save it.
Next go for next image..!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Filtering and Enhancement についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by