I take 4x4 blocks from the Gray image , filtered it and now i want to return it back to the original gray .
1 次查看(过去 30 天)
显示 更早的评论
Dear all ;
I have a gray image . I convert it to DCT . Then i take 4x4 blocks from this DCT of the gray image . I convert the 4x4 dct blocks to idct . Then i filter this 4x4 .
Now i want to take the filtered 4x4 and put it to the original gray image . How ?!
The code is the following :
% Convert to DCT: gray3=dct2(gray2); gray4=gray3(1:4,1:4);
% Convert to idct : IDCT_Gray=idct2(gray4);
%then i filter IDCT_Gray.
Assume the filter output is yy2 . How can i return this 4x4 filter output to the original gray image .
thank you
0 个评论
采纳的回答
sixwwwwww
2013-10-24
Dear Zgrt, you can do it the following way:
gray3=dct2(gray2);
gray4=gray3(1:4,1:4);
IDCT_Gray=idct2(gray4);
h = fspecial('motion'); % Its a sample filter, you can choose according to your need
yy2 = imfilter(IDCT_Gray, h); % Applying the filter to extracted part
gray2(1:4, 1:4) = uint8(yy2); % Putting the back the precessed extracted part into the gray image
I hope it helps. Good luck!
3 个评论
sixwwwwww
2013-10-24
Basically the problem in this technique is that in your gray image you have values in uint8 data type and when you convert it DCT you get values in double data type. The values in uint8 range from 0-255. See http://www.mathworks.com/help/matlab/ref/intmax.html
however in double data type values range from about 10^+308. See http://www.mathworks.com/help/matlab/ref/realmax.html. So when you perform filtering on double double data type they remain double data type and values are typically very large. So when you convert these values back to unit8 type then values are fixed to maximum value of uint8 which is 255. That's the reason that you don't see anything interesting
更多回答(2 个)
Image Analyst
2013-10-27
Sounds like you have it solved since you marked this as accepted but I didn't understand it. I don't know anything about compression (if that's what you're doing) but your explanation of the algorithm, which makes no sense to me. You say you convert an image to DCT, then you take 4x4 blocks. yet your code only deals with the first block, not all of them. Then you inverse transform it, which will of course not give you the same size image in the spatial domain that you started with, but a 4x4 spatial domain image. Perhaps you wanted to zero out the other blocks, maintaining the same size spectrum, rather than extracting 14 elements from it.
But anyway, you then have a very, very tiny, very, very blurry spatial domain image again. But now you say you want to filter it . Strange, because you were just in the Fourier domain and already filtered it there (by taking just a 4x4 chunk of it) so why filter it again in the spatial domain??? And exactly what type of spatial domain filtering can you have with only 4 by 4 pixels? Nothing of any use, I would think.
But whatever....at least you have it solved (whatever it is).
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Computer Vision with Simulink 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!