Why I cant use the same for loop to interpolate the colomn? Only in row.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dingbang Liang
le 29 Mai 2018
Modifié(e) : Ameer Hamza
le 29 Mai 2018
Lena_half = imread('lena_half.tif');
Row = 512; % interp1 along row
[m,n,p] = size(Lena_half);
Enlarge_lena = zeros(m, Row, p);
xi = linspace(1, n, Row);
for i = 1:n
for j = 1:p
Enlarged = interp1(1:n,double(Lena_half(i,:,j)),xi);
Enlarge_lena(i,:,j) = Enlarged;
end
end
Enlarge_lena = uint8(Enlarge_lena);
figure(1)
imshow(Enlarge_lena)
Col = 512;
[a,b,c] = size(Enlarge_lena);
Enlarge_lenaCol = zeros(Col, b, c);
yi = linspace(1, a, Col);
for d = 1:a
for o = 1:c
Enlagred_le = interp1(1:a,double(Enlarge_lena(o,:,d)),yi);
Enlarge_lenaCol(o,:,d) = Enlarged_le;
end
end
Enlarge_lenaCol = uint8(Enlarge_lenaCol);
figure(2)
imshow(Enlarge_lenaCol)
I want to enlarge the whole image. Not only in one side, I want to make it 512*512.
0 commentaires
Réponse acceptée
Ameer Hamza
le 29 Mai 2018
Modifié(e) : Ameer Hamza
le 29 Mai 2018
You are making a mistake in indexing and length of for loops. Compare it with the following code to see the mistake. Also, there was a typo in two occurrences of Enlarged_le
Lena_half = imread('lena_half.tif');
Row = 512; % interp1 along row
[m,n,p] = size(Lena_half);
Enlarge_lena = zeros(m, Row, p);
xi = linspace(1, m, Row);
for i = 1:m % <---- You want to iterate on all rows, not columns
for j = 1:p
Enlarged = interp1(1:n,double(Lena_half(i,:,j)),xi);
Enlarge_lena(i,:,j) = Enlarged;
end
end
Enlarge_lena = uint8(Enlarge_lena);
figure(1)
imshow(Enlarge_lena)
Col = 512;
[a,b,c] = size(Enlarge_lena);
Enlarge_lenaCol = zeros(Col, b, c);
yi = linspace(1, a, Col);
for d = 1:b % <--- Iterate on all columns, not rows.
for o = 1:c
Enlarged_le = interp1(1:a,double(Enlarge_lena(:,d,o)),yi); % <-- indexing issue
Enlarge_lenaCol(:,d,o) = Enlarged_le; % <-- indexing issue
end
end
Enlarge_lenaCol = uint8(Enlarge_lenaCol);
figure(2)
imshow(Enlarge_lenaCol)
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!