Filter löschen
Filter löschen

Why the dimensions of my picture in pixels is reduced when I save my image?

3 Ansichten (letzte 30 Tage)
Hi,
I filter an imageA with a function called bpass and then I display it with imagesc to be able to save it (as .tif). ImageA is 1038*1388 pixels, my filtered image is 1038*1388 double as well, but when I save it (right click on the image, save as...), the picture I then open is 560*420 pixels. Why...?
%Read the image
prepreim = imread('well8 aft.tif');
preim = rgb2gray(prepreim); % Convert uint8 color to uint8 gray scale.
im = double(preim); % Convert to double in the range 0-255.
%spatially filter the image
b = bpass(im,1,4);
figure
colormap gray
imagesc(b)
%save the filtered image
figure, colormap gray, imagesc(b);
set(gca,'xtick',[],'ytick',[]); %remove axis
set(gca,'LooseInset',get(gca,'TightInset')); %remove white band
Not to save it manually, I tried to add the line
saveas(gcf,'8beffilter','tiffn');
But in this case I obtain a picture of dimension 875*656 pixels.
Thank you for your help.

Akzeptierte Antwort

Image Analyst
Image Analyst am 3 Feb. 2017
That probably saves the whole figure, not the image. Use imwrite() instead to save the image array only.
  6 Kommentare
Image Analyst
Image Analyst am 3 Feb. 2017
You'll need to also give us code for bpass().

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

John BG
John BG am 3 Feb. 2017
if the bpass function is removing samples to low band pass filter, then the resulting image is going to be smaller.
have you checked that images b and im are same size?
John BG
  2 Kommentare
Walter Roberson
Walter Roberson am 3 Feb. 2017
"my filtered image is 1038*1388 double as well"
Aude Rapet
Aude Rapet am 3 Feb. 2017
Yes I checked :
>> whos im
Name Size Bytes Class Attributes
im 1038x1388 11525952 double
>> whos b
Name Size Bytes Class Attributes
b 1038x1388 11525952 double

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by