"Invalid graphics handle" error when using imrect() or imellipse()

8 ビュー (過去 30 日間)
Bissem Gill
Bissem Gill 2018 年 7 月 30 日
編集済み: Bissem Gill 2018 年 7 月 31 日
I'm trying to apply a mask onto an image for processing, but the call:
h = imrect(output,[2 3 4 5]); %xmin ymin width height
aways gives me the errors:
Error using roiParseInputs (line 75) HPARENT must be a valid graphics handle.
Error in imrect>imrectAPI (line 182) [commonArgs,specificArgs] = roiParseInputs(0,2,varargin,mfilename,{'DrawAPI'});
Error in imrect (line 82) [h_group,draw_api] = imrectAPI(varargin{:});
I have no clue how to resolve this error.
\removed code\

採用された回答

Adam Danz
Adam Danz 2018 年 7 月 30 日
The first step is always to check your inputs.
help imrect
You'll see that the first input to this function is an axis handle. Try this (or better yet, the actual handle to your axes).
h = imrect(gca, output,[2 3 4 5]);
  1 件のコメント
Bissem Gill
Bissem Gill 2018 年 7 月 30 日
編集済み: Bissem Gill 2018 年 7 月 30 日
Edit: Nevermind, I just needed to include 'figure;' before my function. Thanks Adam!
Thanks Adam. For some reason, when I modify my imrect() to be exactly what you've typed here, I end up getting:
Error using roiParseInputs>checkPreParamNargin (line 153) Too many input arguments.
I'm a little confused, because I think I'm following the inputs correctly as per the documentation.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by