How do I resize an image displayed using imagesc() in a figure?
67 次查看(过去 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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/400064/image.png)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/505903/image.png)
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!