How do I resize an image displayed using imagesc() in a figure?
조회 수: 104 (최근 30일)
이전 댓글 표시
Hi,
How do I resize the images below so they are all the one size?
function [Edges, Ihor, Iver] = edgeExtraction(Iin,B1,B2)
Iin = im2double(Iin);
% Iver = Iin .* B1;
% Ihor = Iin .* B2;
% Edges = edge(Iin);
Ihor = conv2(Iin, B2);
Iver = conv2(Iin, B1);
Edges = sqrt((Iver.^2) + (Ihor.^2));
subplot(1,4,2), imagesc(Ihor), title('Horizontal')
subplot(1,4,3), imagesc(Iver), title('Vertical')
subplot(1,4,4), imagesc(Edges), title('Edges')
end
clear all
close all
boatN = imread('boatnois.jpg');
B1 = [-1 0 1; -1 0 1; -1 0 1];
B2 = [-1 -1 -1; 0 0 0; 1 1 1];
figure(1)
subplot(1,4,1), imshow(boatN), title('Boat');
edgeExtraction(boatN, B1, B2)
댓글 수: 0
답변 (3개)
Walter Roberson
2020년 11월 5일
imagesc() accepts properties 'XData' and 'YData', or you can pass x and y coordinates as the first two parameters to imagesc()
The x you pass should be a vector of two values, the first is the data x coordinate for the center of the lower-left pixel, and the second is the data x coordinate for the center of the upper-right pixel. Likewise for the y, and again the values are data coordinates for centers.
This does not resize the image in the sense of changing the number of pixels in the image array: this instead tells MATLAB where to draw the image, with the image being visually expanded or compacted as necessary in order to fit those data coordinates.
댓글 수: 0
yanqi liu
2021년 2월 1일
clc; clear all; close all;
boatN = imread('football.jpg');
B1 = [-1 0 1; -1 0 1; -1 0 1];
B2 = [-1 -1 -1; 0 0 0; 1 1 1];
figure(1)
subplot(1,4,1), imshow(boatN), title('Boat');
edgeExtraction(boatN, B1, B2)
function [Edges, Ihor, Iver] = edgeExtraction(Iin,B1,B2)
if ndims(Iin) > 2
Iin = rgb2gray(Iin);
end
Iin = im2double(Iin);
% Iver = Iin .* B1;
% Ihor = Iin .* B2;
% Edges = edge(Iin);
Ihor = conv2(Iin, B2);
Iver = conv2(Iin, B1);
Edges = sqrt((Iver.^2) + (Ihor.^2));
subplot(1,4,2), imagesc(Ihor), title('Horizontal')
axis equal
axis tight
subplot(1,4,3), imagesc(Iver), title('Vertical')
axis equal
axis tight
subplot(1,4,4), imagesc(Edges), title('Edges')
axis equal
axis tight
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!