2D filter increases saved file size
古いコメントを表示
I have a question regarding spatial filtering... In the following (greatly) downsized example,
a = y0(1:100,1:2,1);
a = reshape(a,10,10,2);
r = zeros(size(a));
F = fspecial('gaussian');
for i = 1:2
r(:,:,i) = filter2(F,a(:,:,i));
end
save('r.mat','r')
save('a.mat','a')
the saved file a.mat has size 1Kb; and r.mat (2Kb). What leads to the increase in file size? (both 'a' and 'r' has the same dim and uses the same wrkspace memory).
Thanks!
採用された回答
その他の回答 (3 件)
Image Analyst
2011 年 11 月 2 日
1 投票
If you think about it you'll realize why the filtered image is bigger. The filter will "touch" the edge of the image even when the center of the filter is outside the bounds of the image. If you want filter2() to crop it to the same size, you can pass it the 'same' option.
2 件のコメント
Jan
2011 年 11 月 2 日
@bb: If you have a question concerning the command filter2, "help filter2" and "doc filter2" are very recommended. The documentation is written to solve such questions.
bb
2011 年 11 月 2 日
移動済み: Rena Berman
2023 年 12 月 28 日
Jan
2011 年 11 月 2 日
0 投票
Does a have the type double?
MAT files are compressed, if they are saved in the v7.3 style. Then the compression of a.mat has been more efficient than the compression of r.mat. But this shouldn't affect your work in any way.
2 件のコメント
bb
2011 年 11 月 2 日
Image Analyst
2011 年 11 月 2 日
I have my doubts. What does it say if you issue this command:
class(a)
Bjorn Gustavsson
2011 年 11 月 2 日
0 投票
Then this puzzles me a bit. In my case filtered images have less noise and compress better. Are your image a synthetic, or even binary with a sparse number of non-zero pixels? If so, then the filtered image might have more non-zero pixels.
If the loading (and saving) of your filtered images takes longer time than it woudl take to load and filter the original image then you might as well just not save the processed images, but rather preprocess them on the fly as needed.
カテゴリ
ヘルプ センター および File Exchange で Blue についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!