How can I downsample an image?
10 次查看(过去 30 天)
显示 更早的评论
Hello
I want to downsample an image and I want to replace one pixel in new Image with average of four pixel in first image.
Could you help me ?
0 个评论
采纳的回答
Walter Roberson
2015-7-2
Letting the image be IM and assuming it is double(),
NewImage = (IM(1:2:end, 1:2:end) + IM(2:2:end, 1:2:end) + IM(1:2:end, 2:2:end) + IM(2:2:end, 2:2:end)) / 4;
3 个评论
Walter Roberson
2015-7-5
This formula processes all pixels in the image at the same time. I just noticed that it will fail if the height or width are odd.
It works by taking the average of the pixels at (I,J), (I+1,J), (I,J+1), (I+1,J+1), doing so for every second row and ever second column.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!