Controlling the color of crosshair raised by ginput
97 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Naum Derzhi
am 1 Dez. 2017
Kommentiert: jiawei
am 8 Mär. 2025 um 6:58
Hello, I need to use ginput. It "raises raises crosshair in the axes" - which is fine. Unfortunately, this crosshair is black, and in the axes where I need this function the background is, usually, black too, so the crosshair is very difficult to see. Changing background is not really an option. Until now I used an old version of Matlab, where this crosshair was drawn in XOR mode, and therefore this problem did not appear. Now i am forced to upgrade to the most current version, and now the XOR is banished by Mathworks. This creates problems in the described use case, but also in other use cases. Any ideas will be greatly appreciated.
Thank you,
Naum Derzhi
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 2 Dez. 2017
You need to modify the built-in ginput() function since they forgot to add this incredibly obvious and needed option of color. For example see my attached code where I changed the [0,0,0] to [1,1,1] (white). Go to line 283
crossHair(k) = uicontrol(fig, 'Style', 'text', 'Visible', 'off', 'Units', 'pixels', 'BackgroundColor', [1 1 1], 'HandleVisibility', 'off', 'HitTest', 'off'); %#ok<AGROW>
and change the color from [1,1,1] to what you want. Those are the R, G, B values in a range of 0 to 1. Then in your code, be sure to call ginputWhite instead of ginput().
You could even make a cross hair by calling plot() instead of uicontrol() and specify a dashed line if you want.
12 Kommentare
Fenris
am 20 Mai 2021
Hello, how do I need to modyfiy the ginput function in order to use numPoints and customColor as input varibles, If I just add customColor and change the line to
crossHair(k) = uicontrol(fig, 'Style', 'text', 'Visible', 'off', 'Units', 'pixels', 'BackgroundColor', customColor, 'HandleVisibility', 'off', 'HitTest', 'off'); %#ok<AGROW>
and try to use my_gInput(numPoints, customColor) I get the error "input argument 'customColor' might be unused".
Thanks a Lot in advance
Image Analyst
am 20 Mai 2021
Then your uicontrol statemente is probably in an if statement where it might likely never be executed.
Weitere Antworten (1)
Julia
am 3 Mär. 2025 um 18:55
This is an old thread, so maybe this is useless but I put it here for the benefit of people who might still have the same question. The attached version allows you to simply specify the colour you want the cross hair in as a second input argument in the shape of an RGB triplet.
2 Kommentare
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!