problem with size of images
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Adam
2016년 9월 14일
I'm not able to view the help for R2015b, but it sounds like it may still be doing that anyway.
답변 (1개)
Geoff Hayes
2016년 9월 14일
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.
imwrite(BI, sprintf('threshbg8B-3.2_15k_0d5_base_x=0mm_y=0mm_C001H001S000100000%d.tif',i));
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!