Assigning Handles to a variable of an image.

3 Ansichten (letzte 30 Tage)
Luke Dineen-Woolnough
Luke Dineen-Woolnough am 9 Mär. 2016
Kommentiert: Geoff Hayes am 14 Mär. 2016
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 Kommentar
Luke Dineen-Woolnough
Luke Dineen-Woolnough am 9 Mär. 2016
Bearbeitet: Geoff Hayes am 9 Mär. 2016
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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Geoff Hayes
Geoff Hayes am 9 Mär. 2016
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 Kommentare
Luke Dineen-Woolnough
Luke Dineen-Woolnough am 14 Mär. 2016
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 am 14 Mär. 2016
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...

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu App Building finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by