Effacer les filtres
Effacer les filtres

problem with size of images

1 vue (au cours des 30 derniers jours)
Efstathios Kontolatis
Efstathios Kontolatis le 14 Sep 2016
I have the following code
imglist=dir('*.tif'); %list of the .tif images
thresh = zeros(512,512,200);
level = zeros(200);
edges_canny = zeros(512,512,200);
for i=1:length(imglist)
name=imglist(i).name;
A=imread(name);
level(i)=graythresh(A); %level of the threshold for Otsu method
BI=im2bw(A,level(i)); %converts the grayscale image to a binary image
thresh(:,:,i)=BI; %save the thresh image
% BIedge=edge(A,'Canny'); %edge detection with Canny method
% edges_canny(:,:,i)=BIedge;
f=figure;set(f, 'Visible', 'off');
imshow(BI);
saveas(f,sprintf('threshbg8B-3.2_15k_0d5_base_x=0mm_y=0mm_C001H001S000100000%d.tif',i))
% k=figure;
% imshow(imfill(edges_canny(:,:,i),'holes')); %fill the holes
% saveas(k,sprintf('canny8B-3.2_15k_0d5_base_x=0mm_y=0mm_C001H001S000100000%d.tif',i))
end
images=dir('threshbg8B-3.2_15k_0d5_base_x=0mm_y=0mm_C001H001S000100000*.tif');
n = {images.name}';
[~,ii] = sort(str2double(regexp(n,'(?<=threshbg8B-3.2_15k_0d5_base_x=0mm_y=0mm_C001H001S000100000)\d*(?=\.tif)','match','once')));
images = images(ii);
close all
It reads a series of images and then thresholds them. My question is:
whos BI
Name Size Bytes Class Attributes
BI 512x512 262144 logical
C=imread(images(1).name);
whos C
Name Size Bytes Class Attributes
C 900x1200x3 3240000 uint8
Why does this happen? C and BI are supposed to be the same. I just put all BI's in a list
  3 commentaires
Efstathios Kontolatis
Efstathios Kontolatis le 14 Sep 2016
I'm using R2015b version
Adam
Adam le 14 Sep 2016
I'm not able to view the help for R2015b, but it sounds like it may still be doing that anyway.

Connectez-vous pour commenter.

Réponses (1)

Geoff Hayes
Geoff Hayes le 14 Sep 2016
Efstathios - you are saving a figure to a file (rather than an image) and so I think that it is reasonable that C is of a different size than BI. In fact, if you display C using imshow, you may see a white border around your image with an axes.
If you wish to save BI to file, then use imwrite as
imwrite(BI, sprintf('threshbg8B-3.2_15k_0d5_base_x=0mm_y=0mm_C001H001S000100000%d.tif',i));

Community Treasure Hunt

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

Start Hunting!

Translated by