필터 지우기
필터 지우기

How I can know the size of a quantized image

조회 수: 2 (최근 30일)
Osama Hussein
Osama Hussein 2016년 2월 15일
댓글: Osama Hussein 2016년 2월 15일
I designed a simple uniform quantizer, it is a part of project, I used 'leena.jpg' image the original size is about 65.8 KB, after running this code:
img = imread('leena.jpg');
figure(1)
imshow(img)
[m,n] = size(img);
M = 8; K = 256/M;
for i = 1:m
for j = 1:n
quant_img(i,j) = floor(img(i,j)/K) * K + (K/2);
end
end
figure(2)
imshow(quant_img)
-----------------
It is clear the image quality reduced, but when I save the two figures (the original and the quantized) as jpg format, I got 14.4 KB for the original and 16.5 KB for the quantized image! When I increase the number of levels (M = 32) the size decrease to 14.8 KB! Why the size of the image is decreasing with increasing the number of levels!! It should be the reverse, right?

채택된 답변

Image Analyst
Image Analyst 2016년 2월 15일
It's a moot question because you should not even be using jpg. Use PNG instead. It will be bigger but at least you won't have JPG artifacts because it's lossless compression, and pretty much the new standard that most people use.
  댓글 수: 7
Image Analyst
Image Analyst 2016년 2월 15일
You're probably saving the figure window itself, rather than just the image. The figure will include things like gray background, tick marks, annotations in the graphical overlay, etc.
Use imwrite() rather than saveas().
Osama Hussein
Osama Hussein 2016년 2월 15일
Ah! Yes I used saveas(). I get it right now.. Thank you :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by