Assigning Handles to a variable of an image.

조회 수: 3 (최근 30일)
Luke Dineen-Woolnough
Luke Dineen-Woolnough 2016년 3월 9일
댓글: Geoff Hayes 2016년 3월 14일
I Need to assign a handles to a variable in my code, however the variable is a variable of an image. I've Taken an image and then reassigned pixel values, to exclude some pixels and highlight others. I now want to take one of those reassigned pixel values and assign a handle to it, so that i can change it as a parameter in a GUI. Can anyone recommend a way of doing this every method I've tried doesn't seem to work. The Relevant code is below. I want to assign a handle to Reassign(C == 3);.
Many Thanks All!
Luke
J = imread('subject04_crisp_v170.png');
%%Pixel Reassign
Pixel_Reassign = J;
Pixel_Reassign(J==4) = 0;
Pixel_Reassign(J==5) = 0;
Pixel_Reassign(J==6) = 0;
Pixel_Reassign(J==7) = 0;
Pixel_Reassign(J==8) = 0;
Pixel_Reassign(J==9) = 0;
Pixel_Reassign(J==10) = 0;
Pixel_Reassign(J==11) = 0;
C = Pixel_Reassign;
%%Increase Tissue Intensity
Reassign = C;
Reassign(C == 1) = 10;
Reassign(C == 2) = 80;
Reassign(C == 3) = 210;
  댓글 수: 1
Luke Dineen-Woolnough
Luke Dineen-Woolnough 2016년 3월 9일
편집: Geoff Hayes 2016년 3월 9일
This is the function executed by the callback
function pushbutton(hObject, eventdata, edit_text_handle, Reassign_handle)
str_entered = get(edit_text_handle,'string');
if str_entered, 0:255;
col_val = str_entered;
else
col_val = str_entered;
end
set(Reassign_handle, col_val);
The callback is
h.buttonfour = uicontrol('style', 'pushbutton', 'position', [30 350 130 20], 'string', 'Adjust Tissue Value');
set(h.buttonfour, 'callback', {@pushbutton, edit_text_handle, Reassign_handle});
However when i run my gui and try and use this functionality i get the following error
Error using set
Invalid handle
Error in pushbutton (line 9)
set(Reassign_handle, col_val);
Error while evaluating UIControl Callback
I cant see why there is an error using set in the way i have.
Any help would be appreciated.
Many Thanks all
Luke

댓글을 달려면 로그인하십시오.

답변 (1개)

Geoff Hayes
Geoff Hayes 2016년 3월 9일
Luke - you are using Reassign_handle as if it were a handle (to a graphics object) at line
set(Reassign_handle, col_val);
and the error message is telling you that this isn't a handle. How is this variable initialized? What does it correspond to? Please post more of your code so that we can get an idea of how it is being used elsewhere in your GUI.
Also, when using set it is to update (set) some property of the handle object. In this case, no property is being set so this may not be the function that you want to be using.
  댓글 수: 8
Luke Dineen-Woolnough
Luke Dineen-Woolnough 2016년 3월 14일
So where Reassign(C == 1) = X, i want to use the slider to update X between 0 and 255. I didn't mean assigning a handle to reassign, apoligies, i meant assigning Reassign to a callback.
Geoff Hayes
Geoff Hayes 2016년 3월 14일
Why did you post the code from the GrayScaleImageHistogramGui.m example in your above comment (with the only difference being the renaming of the function)? It was provided as an example of what you can do. It is no longer clear to me what it is that you are expecting...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by