MATLAB Answers

My batch image processing is only processing the last image of the folder!

1 ビュー (過去 30 日間)
Adriani Sierra
Adriani Sierra 2021 年 5 月 31 日
コメント済み: Amit 2021 年 6 月 6 日
myFolder='C:\Users\adria\MATLAB Drive\HE_ImageData'
S= dir(fullfile(myFolder,'*.tiff'));
for k = 1:
F = fullfile(myFolder,S(k).name);
fprintf(1, 'Reading %s\n', F);
I = imread(F);
% figure
% imshow(I)
end
2. Images properties
% 3.1 Reading and getting the information about the image
% 3.2 Separating the image beetween a map and a RGB channels
Redchannel = I(:,:,1);
% Greenchannel I(:,:,2);
% Bluechannel = I(:,:,3);
% 3.3 Histograms for all three channels
imhist(Redchannel);
title('Red Channel Histogram')
% imhist(REDchannel);
Hello, I am having the following issue, I am doing a batch processing for 40 images. I have already writen the code, however, when I try to apply the code for all the 40 images, as you see I have to separate the images into three channels, it only process image number 9. The images are being read 1,10(...)19, 2,21 (...)29, 3,31(..) 4, 5 , 6, 7 , 8, 9 being 9 the only image processed. I have tried everything. I have read a lot here in the forum trying to solve this issue. Can someone help me, so I can just have all the images processed?

採用された回答

Subhadeep Koley
Subhadeep Koley 2021 年 6 月 1 日
You're calculating imhist() outside of the for loop that is why only the last read image is being processed. You need to use the "processing code" inside the for loop. The below code might help.
myFolder = "C:\Users\adria\MATLAB Drive\HE_ImageData";
S = dir(fullfile(myFolder, '*.tiff'));
for idx = 1:numel(S)
fullFileName = fullfile(myFolder, S(idx).name);
fprintf(1, 'Reading %s\n', fullFileName);
img = imread(fullFileName);
redChannel = img(:, :, 1);
figure
imhist(redChannel)
title(['Image ', num2str(idx), ' Red Channel Histogram'])
end
  3 件のコメント
Amit
Amit 2021 年 6 月 6 日
For calibrating area you need to know magnification of your image, or ppi (pixel per inches ) or pixel per sqmm of image.
having this information you can detetermine size of complete image in mm or micron and according you can measure/calibrate any unit length or dimensions of any region.
You can try above approach which should work for you.
Else, you can send me your image in actual scale on amit.kenjale@gmail.com, will check image and write source code for both calibration and measurement of images.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by