My batch image processing is only processing the last image of the folder!
3 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Subhadeep Koley
on 1 Jun 2021
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 Comments
Amit
on 6 Jun 2021
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.
More Answers (0)
See Also
Categories
Find more on Biomedical Imaging in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!