Matlab image spatial resolution, change pixel
Mostrar comentarios más antiguos
Hi, how can ı change 8 bit image's pixel numbers like these? Help please


Respuesta aceptada
Más respuestas (2)
You can try imresize()
im = imread('image_1.png');
for ii = 1:6
subplot(2,3,ii);
imshow(imresize(im,2^-(ii-1)));
end
9 comentarios
akevg akevg
el 19 de Mzo. de 2022
Voss
el 19 de Mzo. de 2022
Since it worked, do you mind accepting the answer? I appreciate it!
Image Analyst
el 19 de Mzo. de 2022
Editada: Image Analyst
el 19 de Mzo. de 2022
@akevg akevg Note that the output image size is different than the original. With my code below, the image size is the same, it's just blockier looking. Do you want the output image size to be the same or smaller?
akevg akevg
el 19 de Mzo. de 2022
Editada: akevg akevg
el 19 de Mzo. de 2022
akevg akevg
el 19 de Mzo. de 2022
Image Analyst
el 19 de Mzo. de 2022
Editada: Image Analyst
el 19 de Mzo. de 2022
Then you accepted the wrong answer. Watch this:
im = imread('peppers.png');
for ii = 1:6
subplot(2,3,ii);
outputImage = imresize(im,2^-(ii-1));
imshow(outputImage);
axis('on', 'image')
[rows, columns, numColors] = size(outputImage)
caption = sprintf('%d rows by %d columns', rows, columns);
title(caption)
end
Voss
el 19 de Mzo. de 2022
I appreciate that you accepted my answer. However, if you want the same image size, go with @Image Analyst's answer and accept it instead.
akevg akevg
el 19 de Mzo. de 2022
Or you could just do
inpict = imread('peppers.png');
k = 16;
outpict = imresize(imresize(inpict,1/k,'bilinear'),k,'nearest');
imshow(outpict)
[size(inpict); size(outpict)]
Which is far simpler and much faster than using blockproc() for any moderately large image.
Of course, it depends how much control one wants over exactly which pixels are contributing to each block and how exactly they're being weighted. I'm assuming that the goal here has no technical requirements, as none were given.
Image Analyst
el 19 de Mzo. de 2022
0 votos
Use blockproc(). Solution attached.


1 comentario
akevg akevg
el 19 de Mzo. de 2022
Categorías
Más información sobre Convert Image Type en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



