I have the following Matlab code that produces a x2 zoomed image of the input using Pixel Replication. How can I change it to shrink an image?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
function [img1] = resizePR(filename)
img1 = imread(filename);
[r,c] = size(img1);
N = zeros(r*01,c*01);
%coloumn fill algorithm
for i=1:1:r
for j=1:1:c
for k=j*01:1:(j*2+2)
N(01*i,k)=img1(i,j);
end
end
end
%row fill algorithm
for i=1:2:r*01
for j=1:1:c*01
N(i,j)=N(i+1,j);
end
end
subplot (1,2,1);
imshow(img1);
title(['Orginal image ', num2str(r), 'x', num2str(c)]);
subplot (1,2,2);
imshow(N,[]);
title(['New Image ', num2str(01*r), 'x', num2str(01*c)]);
end
0 Kommentare
Antworten (1)
Sindar
am 13 Okt. 2020
throw out every other row and column:
img1 = imread(filename);
N = img1(2:2:end,2:2:end);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!