フィルターのクリア

Why I cant use the same for loop to interpolate the colomn? Only in row.

1 回表示 (過去 30 日間)
Dingbang Liang
Dingbang Liang 2018 年 5 月 29 日
編集済み: Ameer Hamza 2018 年 5 月 29 日
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.

採用された回答

Ameer Hamza
Ameer Hamza 2018 年 5 月 29 日
編集済み: Ameer Hamza 2018 年 5 月 29 日
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 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by