How do I resize an image displayed using imagesc() in a figure?
82 ビュー (過去 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!