Figure 창에 출력되는 이미지 크기 조절 방법

안녕하세요.
Figure 창에 출력되는 결과가 전체의 부분만 나타납니다. 처리하는 이미지 크기가 커서 그런것 같아서 이미지 크기를 줄여도 동일한 형태인데. Figure에 출력되는 이미지가 계속 부분만 보이는 이유가 무엇인지 조언 부탁 드립니다.
scale_factor = 0.5;
radius_range_orig = [15 60];
img1_rgb_orig = imread('SIFT_1.png');
Error using imread>get_full_filename (line 635)
Unable to find file "SIFT_1.png".

Error in imread (line 395)
fullname = get_full_filename(filename);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
img1_rgb = imresize(img1_rgb_orig, scale_factor);
img1_gray = im2gray(img1_rgb);
img2_rgb_orig = imread('SIFT_2.png');
img2_rgb = imresize(img2_rgb_orig, scale_factor);
img2_gray = im2gray(img2_rgb);
points1_all = detectSIFTFeatures(img1_gray);
points2_all = detectSIFTFeatures(img2_gray);
scaled_radius_range = round(radius_range_orig * scale_factor);
[centers1, radii1] = imfindcircles(img1_gray, scaled_radius_range, 'Sensitivity', 0.92, 'ObjectPolarity', 'bright');
if isempty(centers1)
disp('SIFT_1.png (축소됨)에서 공을 찾지 못했습니다. 반경/민감도를 조절하세요.');
return;
end
center1 = centers1(1,:);
radius1 = radii1(1);
roi1 = [center1(1)-radius1, center1(2)-radius1, 2*radius1, 2*radius1];
[centers2, radii2] = imfindcircles(img2_gray, scaled_radius_range, 'Sensitivity', 0.92, 'ObjectPolarity', 'bright');
if isempty(centers2)
disp('SIFT_2.png (축소됨)에서 공을 찾지 못했습니다. 반경/민감도를 조절하세요.');
return;
end
center2 = centers2(1,:);
radius2 = radii2(1);
roi2 = [center2(1)-radius2, center2(2)-radius2, 2*radius2, 2*radius2];
locations1 = points1_all.Location;
x_min1 = roi1(1); y_min1 = roi1(2);
x_max1 = roi1(1) + roi1(3); y_max1 = roi1(2) + roi1(4);
inside_indices1 = (locations1(:, 1) >= x_min1 & locations1(:, 1) <= x_max1 & ...
locations1(:, 2) >= y_min1 & locations1(:, 2) <= y_max1);
points_in_roi1 = points1_all(inside_indices1);
locations2 = points2_all.Location;
x_min2 = roi2(1); y_min2 = roi2(2);
x_max2 = roi2(1) + roi2(3); y_max2 = roi2(2) + roi2(4);
inside_indices2 = (locations2(:, 1) >= x_min2 & locations2(:, 1) <= x_max2 & ...
locations2(:, 2) >= y_min2 & locations2(:, 2) <= y_max2);
points_in_roi2 = points2_all(inside_indices2);
[features1, valid_points1] = extractFeatures(img1_gray, points_in_roi1);
[features2, valid_points2] = extractFeatures(img2_gray, points_in_roi2);
indexPairs = matchFeatures(features1, features2, 'MaxRatio', 0.6);
matchedPoints1 = valid_points1(indexPairs(:, 1), :);
matchedPoints2 = valid_points2(indexPairs(:, 2), :);
figure('WindowState', 'maximized');
showMatchedFeatures(img1_rgb, img2_rgb, matchedPoints1, matchedPoints2, 'montage');
title('Matched SIFT Features (Resized Image)');

6 Comments

William Rose
William Rose on 21 Oct 2025
Google translation to English:
Hello. The output in the Figure window only shows a portion of the entire image. I suspect this is due to the large size of the image being processed. Even if I reduce the image size, the result remains the same. Could you please advise why the image displayed in the Figure window continues to show only a portion of the entire image?
Please attach image files SIFT_1.png and SIFT_2.png.
SIFT_1.png 및 SIFT_2.png 이미지 파일을 첨부해 주세요.
In the following test, the SIFT images in the code have been replaced with the stock image "peppers.png". The code can run without errors. If the image size exceeds 5 MB, you may encounter difficulties attaching the image files SIFT_1.png and SIFT_2.png.
scale_factor = 0.5;
radius_range_orig = [15 60];
img1_rgb_orig = imread('peppers.png');
img1_rgb = imresize(img1_rgb_orig, scale_factor);
img1_gray = im2gray(img1_rgb);
img2_rgb_orig = imread('peppers.png');
img2_rgb = imresize(img2_rgb_orig, scale_factor);
img2_gray = im2gray(img2_rgb);
points1_all = detectSIFTFeatures(img1_gray);
points2_all = detectSIFTFeatures(img2_gray);
scaled_radius_range = round(radius_range_orig * scale_factor);
[centers1, radii1] = imfindcircles(img1_gray, scaled_radius_range, 'Sensitivity', 0.92, 'ObjectPolarity', 'bright');
if isempty(centers1)
disp('SIFT_1.png (축소됨)에서 공을 찾지 못했습니다. 반경/민감도를 조절하세요.');
return;
end
center1 = centers1(1,:);
radius1 = radii1(1);
roi1 = [center1(1)-radius1, center1(2)-radius1, 2*radius1, 2*radius1];
[centers2, radii2] = imfindcircles(img2_gray, scaled_radius_range, 'Sensitivity', 0.92, 'ObjectPolarity', 'bright');
if isempty(centers2)
disp('SIFT_2.png (축소됨)에서 공을 찾지 못했습니다. 반경/민감도를 조절하세요.');
return;
end
center2 = centers2(1,:);
radius2 = radii2(1);
roi2 = [center2(1)-radius2, center2(2)-radius2, 2*radius2, 2*radius2];
locations1 = points1_all.Location;
x_min1 = roi1(1); y_min1 = roi1(2);
x_max1 = roi1(1) + roi1(3); y_max1 = roi1(2) + roi1(4);
inside_indices1 = (locations1(:, 1) >= x_min1 & locations1(:, 1) <= x_max1 & ...
locations1(:, 2) >= y_min1 & locations1(:, 2) <= y_max1);
points_in_roi1 = points1_all(inside_indices1);
locations2 = points2_all.Location;
x_min2 = roi2(1); y_min2 = roi2(2);
x_max2 = roi2(1) + roi2(3); y_max2 = roi2(2) + roi2(4);
inside_indices2 = (locations2(:, 1) >= x_min2 & locations2(:, 1) <= x_max2 & ...
locations2(:, 2) >= y_min2 & locations2(:, 2) <= y_max2);
points_in_roi2 = points2_all(inside_indices2);
[features1, valid_points1] = extractFeatures(img1_gray, points_in_roi1);
[features2, valid_points2] = extractFeatures(img2_gray, points_in_roi2);
indexPairs = matchFeatures(features1, features2, 'MaxRatio', 0.6);
matchedPoints1 = valid_points1(indexPairs(:, 1), :);
matchedPoints2 = valid_points2(indexPairs(:, 2), :);
figure('WindowState', 'maximized');
showMatchedFeatures(img1_rgb, img2_rgb, matchedPoints1, matchedPoints2, 'montage');
title('Matched SIFT Features (Resized Image)');
dpb
dpb on 21 Oct 2025
@성완 -- how large are the original images and how much have you decimated them by for testing?
Can you load and display them alone?
성완
성완 on 21 Oct 2025
Hi all,
Appreciate all of your comment. I added original image for your reference. Image dimensions = 950 X 1569.
Thank you!
The figure is normal on the forum (not saying the feature matching is working).
Could this be some sort of thing either to do with Mac and/or a new version?
Unless there is other stuff going on during figure manipulation/setup, I don't see how someone could just casually get the axes position offset like that.
I don't know how the windowstate option behaves in newer versions, but I don't believe it's being applied when used on the forum, so that may be another thing we're not actually testing.
% the same code as before (no sense repeating it)
% ...
get(gcf,'windowstate') % it's not actually applied here
ans = 'normal'
성완
성완 on 22 Oct 2025
Hi
I'm running the script with MacBook Pro 16inch model. Anyhow, I just run same script on my extend monitor(32inch), and I can check normal figure image. Let me update Matlab as new version and try it later.
Appreciate all of your help!

Sign in to comment.

Answers (0)

Asked:

on 21 Oct 2025

Commented:

on 22 Oct 2025

Community Treasure Hunt

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

Start Hunting!