hi guys, I have this problem i have been trying to fix without any success. I would be grateful if you could give it a look.
I have few images (4) all named like this: a_484 , a_485, a_486, a_487. All images are the same.
The first part of the script works just fine but i cant save the new images as i would like.
for example: let's say for each image matlab generates the picture of 10 bouding boxes. I would like to save those bounding box images in a new folder likewise: a_484_1, a_484_2, a_484_3, a_484_4, ..., a_484_10 - a_485_1, a_485_2, a_485_3, etc etc for each of them.
I will attach my script.
dirName = uigetdir('./', 'Select data folder');
cd(dirName);
for i=484:487
image_{i}=imread(sprintf('a_%03d.tif',i));
BW=image_{i}>3500;
figure,imshow(BW);
labeledImage = bwlabel(BW);
measurements = regionprops(labeledImage, 'BoundingBox', 'Area');
for k = 1 : length(measurements)
thisBB = measurements(k).BoundingBox;
image2_{i}=imcrop(image_{i},[thisBB(1),thisBB(2),thisBB(3),thisBB(4)]);
[rows cols depth]=size(image2_{i});
if rows*cols>100
figure,imshow(image2_{i});
colormap (jet)
colorbar
caxis([0 45000]);
axis on
end
end
baseFileName = sprintf('a_%03d_%k.tif', i, k);
fullFileName = fullfile('C:...\new', [baseFileName, num2str(i),'.tif']);
imwrite(image2_{i},fullFileName)
end