2013-06-25 3 views
0
clear all; close all; clc; 
A = im2double(imread('cameraman.jpg')); 
figure(1) 
imshow(A) 

C = chunking(A,400,400) % separates picture; 
[m n] = size(C); 
k = 1; 
figure(1) 
for i = 1:m 
    for j = 1:n 
     subplot(m,n,k) 
     imshow(C{i,j}) 
     axis off; 
     k = k + 1; 

    end 
end 

그래서 위의 코드에서 그림을 400x400 픽셀 청크로 분리하려고합니다. 이미지는 400x400의 배수가 아니기 때문에 테두리와 오른쪽 하단 모서리에 부등호 섹션 (여전히 정사각형 이미지)이 있습니다. 그러나 subplot을 사용하면 마지막 크기가 동일한 크기가되도록 크기가 조절됩니다. 나는 GET과 놀아 위치를 설정 합니다만, 각각의 부가 적 줄거리의 폭과 높이가 같은 것을 제공 시도?! [1]Matlab에서 다중 서브 그림의 축을 설정하는 방법

http://imgur.com/2VUYZr1

답변

0

당신은 축의 경우 크기를 조정하려면 [여기 이미지 설명을 입력합니다] 표시 할 픽셀 수가 400 개 미만입니다. 핸들을 각 하위 플롯에 저장 한 다음 크기가 더 작은 경우 크기를 조정해야합니다.

부가 적 줄거리에 대한 귀하의 호출은 다음과 같아야합니다

h = subplot(m,n,k); 
num_rows = size(C{i,j}, 1); 
num_cols = size(C{i,j}, 2); 
set(h, 'units', 'pixels') 
old_axes_pos = get(h, 'position'); 
new_axes_pos = old_axes_pos; 
if num_cols < 400 
    new_axes_pos(3) = num_cols; % Make this axes narrower 
end 
% If the figure cannot be full height 
if num_rows < 400 
    new_axes_pos(4) = num_rows; % Make this axes shorter 
    new_axes_pos(2) = old_axes_pos(2) + (400 - num_rows); % Move the bottom up 
end 
set(h, 'position', new_axes_pos) % Change the size of the figure 
관련 문제