Info

此问题已关闭。 请重新打开它进行编辑或回答。

Getting size of a browsed image

1 次查看(过去 30 天)
Hassan Bosha
Hassan Bosha 2019-3-27
关闭: MATLAB Answer Bot 2021-8-20
I want to take the height and width of the inserted (browsed) picture to use the height and width in a condtion
i'm browsing two pictures , i want the them to have the same size
so i already have the first picture , if the of the size of the second one is equal to the first one, then display it
if it's not resize the second picture with the same of the first one and display it
i'm using GUI
That's my code for browisng button , how can i do it ?
% --- Executes on button press in Browse_Image1.
function Browse_Image1_Callback(hObject, eventdata, handles)
[FileName,PathName] = uigetfile({'*.JPg';'*.tif';'*.gif';'*.png'});
filename = fullfile(PathName,FileName);
myImage1 = imread(filename);
gray1=rgb2gray(myImage1);
% get size of the first one
axes(handles.axes1);
imshow(gray1);
function Browse_Image2_Callback(hObject, eventdata, handles)
if ( Height2 = Height1 && Width2 = Width1)
{
[FileName,PathName] = uigetfile({'*.JPg';'*.tif';'*.gif';'*.png'});
filename = fullfile(PathName,FileName);
myImage2 = imread(filename);
gray2 = rgb2gray(myImage2);
axes(handles.axes2);
imshow(gray2);
}
else
{
[FileName,PathName] = uigetfile({'*.JPg';'*.tif';'*.gif';'*.png'});
filename = fullfile(PathName,FileName);
myImage2 = imread(filename);
gray2 = rgb2gray(myImage2);
grayresiz2 = imresize(gray2,[Height1,Width1]);
axes(handles.axes2);
imshow(grayresiz2);
}

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by