Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
I am attempting to plot histograms for batch of images in Matlab. The file structure of input images and the experimental implementation are listed as below.
File structure of input images
The matlab code
HistogramPlotting.mfile is placed in the project root folder and there are multiple folders which is named by its data index number for placing input images. For example, there are
2/2.bmp, …, etc. The output histograms for the same data index are in a folder “<data_index>/Histograms/”. For example, the results of images in folder
1/are placed in folder
- / | - HistogramPlotting.m | - 1/ | - Histograms/ <= This folder will be created for placing histogram outputs | - 1.bmp | - 2.bmp | - 3.bmp | - 4.bmp ...
Histogram plotting implementation (
VideoLength = 100; for DataIndex = 1:10 for i = 1:VideoLength InputFileName = sprintf("%s%d%s%d%s", "./", DataIndex, "/", i, ".bmp"); if (isfile(InputFileName) == false) continue; end image = imread(InputFileName); f = figure; f.Position = (100 100 540 400); histogram(image); xlabel('Intensity'); ylabel('Count'); title(sprintf("Histogram (%d)", i)); OutputFoldername = sprintf("%s%d%s", "./", DataIndex, "/Histograms/"); mkdir(sprintf("%s", OutputFoldername)); OutputFilename = sprintf("%s%d%s", OutputFoldername, i, ".bmp"); saveas(gcf, OutputFilename); close(f); end end
All suggestions are welcome.