Showing Alert of empty axes box.

2 ビュー (過去 30 日間)
Rya
Rya 2017 年 6 月 1 日
コメント済み: Walter Roberson 2017 年 6 月 3 日
When the Axes Box does not contain any image and user clicks on the Push button then an error should popup saying "Please upload an image" or something else, how to do that how check whether the axes box is empty or not?
  2 件のコメント
Jan
Jan 2017 年 6 月 1 日
Please provide any details. Show us the relevant part of the code, e.g. the button's callback. Do you have the handle of the axes? Does the axes contain any other child objects? What about setting a flag, when the image is imported?
Rya
Rya 2017 年 6 月 1 日
like this is main screen, i want to put a check that when user doesn't go in proper order i.e click on 'matching' at first it should make alert that upload image first similar case with 'Extract no plate' button

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2017 年 6 月 1 日
Set the 'enable' property of the Extract button to 'off' at the start of the program. When the user has uploaded or captured an image, set the enable property to 'on'. That way it is not possible for the Extract button to be clicked when there is no image to extract from.
  8 件のコメント
Rya
Rya 2017 年 6 月 3 日
yes i made changes in guide also, it still does not work and this is not according to my requirement as well, let me clear u . if there is no image in axes, then clicking on Action buttons like 'extract' and 'match' is something nonsense, i want to alert the user of my project whenever he clicks on any action(button) before loading image a msgbox must popup to alert a user
Walter Roberson
Walter Roberson 2017 年 6 月 3 日
function Load_Callback(hObject, eventdata, handles)
[filename, pathname]=uigetfile({'*.jpg';'*.jpeg';'*.gif';'*.png';'*.bmp'},'Select file');
global MyImage;
MyImage = fullfile(pathname, filename);
im = imread(MyImage);
imshow(im, 'Parent', handles.axes1);
handles.have_loaded_something = 1;
guidata(hObject, handles);
function Extract_Callback(hObject, eventdata, handles)
global MyImage;
global noPlate;
if ~isfield(handles, 'have_loaded_something')
handles.have_loaded_something = 0;
guidata(hObject, handles);
end
if ~handles.have_loaded_something
msgbox('You need to load an image!', 'modal');
return
end
numberPlateExtraction(MyImage);
set(handles.edit1, 'string', noPlate);

サインインしてコメントする。

その他の回答 (2 件)

Adam
Adam 2017 年 6 月 1 日
編集済み: Adam 2017 年 6 月 1 日
Declare e.g.
handles.hImage = [];
at the start of your program, then just set this when you plot the image as e.g.
handles.hImage = imagesc( hAxes,... );
Then in your pushbutton callback you can just test
if isempty( handles.hImage )
errordlg( 'Please upload an image' )
return
end
  16 件のコメント
Image Analyst
Image Analyst 2017 年 6 月 3 日
Why not simply use getimage() like I suggested to find out if there is any image in the axes???
Rya
Rya 2017 年 6 月 3 日
編集済み: Rya 2017 年 6 月 3 日
where should i write in call back function? plz implement your example in above given code

サインインしてコメントする。


Image Analyst
Image Analyst 2017 年 6 月 1 日
You can use getimage() to see if there is any image in the axes. It will be empty if you have not loaded an image yet (with a function such as imshow, image, imagesc, etc.). Use axes() to switch the current axes to the one you care about, then:
theImage = getimage();
if isempty(theImage)
% Nothing is in the current axes.
uiwait(warndlg('Please load an image'));
end

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by