Is it possible to have larger (than 16-by-16) pointer size?

Hi all,
I'm designing a drawing program in matlab (just imagine a simplified Photoshop), where the paintbrush can have larger than 16-by-16 size. I'd like to customize the pointer such that it has exactly the same size and same shape as the paintbrush (e.g. circle). Right now, I can change the shape by customizing PointershapeCData:
set(gcf,'Pointer','custom','PointerShapeCData',cdata,'PointerShapeHotSpot',[9 9]);
But the cdata is limited to 16-by-16, otherwise there will be a error. It seems matlab doesn't support any other sizes.
Is there anyway that I can make the pointer larger than 16-by-16?
Thank you very much in advance!
Best,
Leon

6 Comments

In r2020a the PointerShapeCData also allows for 32x32 but I'm not sure when that happened.
I don't know if it is still relevant to you but since I had the same question and found no answer, I decided to write a little code which you could use as well for your problem.
I wanted the same as you, but with a square around the Cursor.
My image was displayed with "imshow" if that's of relevance.
This code will dispay the edge points of a square around the cursor, since I needed to see what's below the "brush".
I also used only 3s intervals to plot the squares around the Cursor with the option to repeat this process. You can easily tweak this to work as you need.
imshow(someimage);
set(gcf, 'WindowState', 'maximized', 'WindowButtonMotionFcn', @Platzhalter);
%Setting a WindowButtonMotionFcn is important, since otherwise
%axes.CurrentPoint will not update everytime you move the cursor, see later
tic;
hold on
a = []; %Placeholder for the plot later
MP = []; %MP = MittelPunkt = centerpoint, eg Position of the cursor
Ausschnitt = 200; %length of the square around the cursor
StopPlot = 0;
while ~StopPlot
while toc <=3 %looped this for 3s
ax = gca;
MP = [MP;ax.CurrentPoint]; %Saves the Centerpoints, since I needed them, you can as well use just the last Point
x = MP(end,1);
y = MP(end,2);
EckpunkteViereck = [x-Ausschnitt/2, y-Ausschnitt/2;
x+Ausschnitt/2, y-Ausschnitt/2;
x-Ausschnitt/2, y+Ausschnitt/2;
x+Ausschnitt/2, y+Ausschnitt/2];
%Edgepoints of the square
delete(a); %Removes the last square before plotting the new one
a = plot(EckpunkteViereck(:,1), EckpunkteViereck(:,2), 'xb');
drawnow %not sure if this is needed, did not test it without
end
b = plot(EckpunkteViereck(:,1), EckpunkteViereck(:,2), 'or');
%Plots the last place of the square in red, not necessary for
%the process
if waitforbuttonpress %
StopPlot = 1;
xcenter = x; %outputs the last x and y position
ycenter = y;
else
delete(b);
tic; %repeats the process for 3 more s
end
end
hold off
function Platzhalter(~,~)
%does not have to do anything, is jsut necessary so that the
%Cursorposition of the axes updates itself automatically
%must accept 2 inputs though
end
so basically the idea is that with setting a (even empty) WindowButtonMotionFcn you can continously read the current cursor position via
imshow(image)
set(gcf, 'WindowButtonMotionFcn', @emptyfcn);
axes = gca;
Cursorposition = axes.CurrentPoint;
Probably not the most elegant solution but it works.. ;-)
@Tim Kühlthau, I'm a bit lost. Could you help me understand why a pointer can't be used instead of your approach?
@Adam Danz yeah sure.
I have written a script to evaluate pictures taken with a microscope. To measure some structures I need to zoom in on different places which I realized by clicking in to the figure and then plotting part of the image (a square) with the input (ginput is used) as centerpoint and a variable sidelength.
Therefore I wanted to see in advance which part of the image will be zoomed in on. So now the edges of the square around my cursor indicate exactly the area of the zoomed in image.
Using cursors I do not have the possibility to change their size as I want to. For example if the zoomed in area is 200x200px I would have to have a Square Cursor with this sidelength which I could not realize in another way.
Actually I used some kind of similar code to trace the path of my mouse hovering over an image (also with an empty WindowButtonMotionFcn) so I had this part lying around and I tweaked it to plot my "zoom window" around the cursor..
as I said it is for sure not the most elegant solution and if you have a better idea how this could be realized, I am happy to learn new stuff. :)
edit: and with this code the question of this topic could be solved. Just plot a circle around the cursor instead of a square.
I see. In that case I agree that pointer control is insufficient.
I would assign a WindowButtonMotionFcn to the figure that activates when the cursor enters the axes (see example).
The callback function would activate a rectangle object that is centered around the CurrentPoint (position of cursor) with a fixed size.
Then I would assign a ButtonDownFcn to the axes that grabs the coordinates of the rectangle when a mouse button is pressed and then zooms into the image based on the rectangel's coordinates.
You could add an additional element that controls whether the rectangle should appear or not so you can turn this feature off.
Also note that the zoom tool in the axis toolbar allows the user to click-and-drag a rectagular area of an axes and then zooms into that area. It draws a rectangle around the section as your dragging the mouse.
Thank you very much for your input.
If I will have to rework the code of my measurement script I will definitely try it out.
This could also be an answer to corviant_cat's question if a circle instead of a square is plotted around the cursor tho. :)

Sign in to comment.

 Accepted Answer

This is a limitation in the operating systems that support MATLAB, that the fast (hardware) cursor is limited to 16 x 16. To get cursors with larger dimensions they have to be drawn in software.

2 Comments

Thanks! But how come the fullcross cursor can be larger than 16x16? see the following screenshot. Is it possible to modify the behavior of this type of cursor such that it becomes a larger circle? http://i.imgur.com/6cBAV9K.png
fullcross goes through a slightly different hardware path.
The hardware cursors often go through a separate hardware bit-plane so that they are drawn without damaging the contents of the frame buffer. For speed (and cost originally) that hardware is not very flexible

Sign in to comment.

More Answers (1)

Adam Danz
Adam Danz on 16 Apr 2021
Edited: Adam Danz on 16 Apr 2021
> Is there anyway that I can make the pointer larger than 16-by-16?
Update: Starting in r2016b PointerShapeCData can be 16x16 or 32x32.
Resources for creating pointers:

Categories

Community Treasure Hunt

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

Start Hunting!