My batch image processing is only processing the last image of the folder!
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Biomedical Imaging 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!