How to compress the image ?

for example, I have a 3D image in grayscale, 512X512X300.
I just want to compress it in X and Y plane.
I want 4 pixels to combine into one pixel.
And the value of the combined pixel takes average on that 4 pixels or take its max.
Can I directly do on 3D image? If not, please tell me how to do it on 2D image.
Thanks.

답변 (2개)

Image Analyst
Image Analyst 2014년 8월 29일

1 개 추천

Just save it as a .mat file. This is a proprietary binary format that will probably be fairly compressed, and anyway, it will make it convenient to read back in to MATLAB.

댓글 수: 6

tabw
tabw 2014년 8월 30일
Image Analyst,
You are saying I have to save every single 2D image in mat format, right? I guess I can't save 3D image directly,right?
After saving, How to compress in the way I want ?
combining 4pixel into 1 pixel. and How to control its value ?
Just save the whole variable. If the variable is a 3D array, save that.
save(filename, 'array3d');
tabw
tabw 2014년 8월 31일
And then?What should I do next? I guess it is not to use imresize this function to compress ,right?
Image Analyst
Image Analyst 2014년 8월 31일
No you don't use imresize(). That changes the number of rows and columns in the image. save() saves the image to disk with fewer bytes than when it's loaded into memory, or saved to disk with a sequence of uncompressed 2D images. I have no idea what you want to do after that - you didn't say. All you said is you want to compress it (not resize it - they're very very different).
tabw
tabw 2014년 9월 2일
I should state more clearly.
I want to compress the pixel size. maybe say in this way, I want to combine 4 pixels into 1 pixel because my image is too big.
Image Analyst
Image Analyst 2014년 9월 2일
Then use imresize().

댓글을 달려면 로그인하십시오.

Yawar Rehman
Yawar Rehman 2014년 9월 3일

0 개 추천

image analyst is rigth, i think you have a stack 300 gray scale images whose dimensions are 512x512.
compression usually involves techniques like principal components analysis. but from your question it is more evident that you want to downsample an image by the factor of 1/4 rather than compress. i think this would be useful!
% images you have
imgs = zeros(512,512,300);
% downsample by 1/4
downImages = imresize(imgs,1/4);

카테고리

도움말 센터File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

질문:

2014년 8월 29일

답변:

2014년 9월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by