I am new in matlab GUI. I want to drawing lines by dragging the mouse. I found this issue but I want save new image with drawn lines. If i run this line, it will show me the same image.
imshow(im);
How can I get new image with drawn lines and for example show it?
You can also grab the image data directly in the Command Prompt. Once you draw all of your lines on your figure window, you can use getframe, which takes a snapshot of the current frame in focus. In this case, this should be your image with the drawn lines. When you call getframe, this will give you a structure with an element called cdata. This will give you an RGB array of what was seen in the figure (without the menu bars... just the figure data itself).
Example:
im = imread('cameraman.tif');
imshow(im);
h = getframe;
out = h.cdata;
figure;
imshow(out); %// Should give you the same image as the figure
You can use print to print the figure to some file. Not sure if you want to have exact reproduction of your line and image. In this case the best way probably would be to store the coordinates and properties of the line and use that to draw it on the image when you want to display it again later.
Related
I have using https://konvajs.org/docs/sandbox/Free_Drawing.html this first example,but also added image in stage.
But when I erase drawn line, image also removed.
How can I fixe that
The demo is using globalCompositeOperation = destination-out to implement erase function. globalCompositeOperation affects all drawings in a canvas.
To solve the issue you can use another Konva.Layer at the bottom with your image.
Each Konva.Layer has its own canvas element. So it will be not affected by shapes with globalCompositeOperation = destination-out in another layer.
I'm trying to create a PDF document with an image that will be rotated.
I can successfully create the PDF document, add the image and save it, but as soon as I try rotating it, I'm having many issues.
One thing I'm trying to understand is where is the axe for the rotation, is it at 0,0 (bottom left for PDF) or somewhere else?
Here's my current running code:
output = BytesIO()
# create a new PDF with Reportlab
c = canvas.Canvas(output)
c.saveState()
c.translate(X?, Y?) # TODO find this !
c.rotate(45)
c.drawImage('path/to/image.png', position_left, position_top, width=img_width, height=img_height, mask='auto')
c.restoreState()
c.save()
(Since PDF documents (0,0) point is at bottom right, I have position_left and position_top that refers to the top left point of the document, where I want to place the image).
My issue here is that I don't know how what values to put on c.translate(X?, Y?) to make the image rotate on its center axis, i.e. stays at the same position on the document, but rotate on itself from its center point.
Is using c.translate(X?, Y?) would work or do I need to use advanced mechanisms to rotate "just" the image on the PDF document? If so, can you point me to the right track?
Thank you for your help.
You can use the technique mentioned in below SO Thread
A simple method for rotate images in reportlab
from reportlab.platypus.flowables import Image
class RotatedImage(Image):
def wrap(self,availWidth,availHeight):
h, w = Image.wrap(self,availHeight,availWidth)
return w, h
def draw(self):
self.canv.rotate(90)
Image.draw(self)
I = RotatedImage('../images/somelogo.gif')
Just wondering how I can get rid of the imellipse after calling it in MATLAB. Currently I call it, double click it to plot the ellipse on my image, then I want to remove the ellipse tool.
I have a GUI, which I click a pushbutton to make an imellipse. After double clicking the imellipse, an outline is plotted onto my image and the dimensions saved to some matrix.
After double clicking it, resulting in a plot onto my image, I would like the ellipse ring (created from the function) to disappear. It just seems to stick around on the image (is this normal, or should it disappear?).
I can include my code, it just seems irrelevant to the problem (remove imellipse after double clicking).
I hope this is more clear!
Thanks!
imellipse creates a ROI on the figure, which can be removed if you delete the associated ROI object.
Let's suppose you have used imellipse like this -
Lesion = imellipse(handles.axes1);
Then, get all the information that you need from Lesion and then delete it. For example, if you need the mask information from it, store it somewhere.
LesionMask = Lesion.createMask();
Now, delete the ROI object which is Lesion.
delete(Lesion); %// Deletes the ROI related to imellipse
Read more about how to handle ROIs at Region-of-interest (ROI) base class Documentation
I have read a image like that
a = imread('test.jpg');
image(a)
what the test.jpg is:
but after the image function
the result is:
and I don't know why it show that?
Because I want to crop some part, so I have to see the image shown.
How to fix it by showing the human face by image?
You are using image command to display an image. From here: "image creates an image graphics object by interpreting each element in a matrix as an index into the figure's colormap or directly as RGB values". Since you are providing a 2-D matrix, each element is interpreted as the index to the figures colormap. You can see the figure's colormap by using
c_map=colormap;
Also, the axis is set to square, therefore you see a circle instead of an ellipse. Use imshow(a,[]) to display the grayscale image as desired.
You image data might be in a color map instead. try [a,cmap] = imread(...). If cmap is not empty, a is indices into cmap, and cmap contains the actual colors.
Use img = cat(3,cmap(a,1),cmap(a,2),cmap(a,3)) to get your image, and show it with image(img).
Note that using imagesc might be misleading in this case as it will still show something that looks like your image when simply doing imagesc(a). This as different pixels colors are associated with different index-values in a.
How do you say or achieve container.child.source = image.png?
I have a hexagon map built by specifying width and height. I draw a wireframe and place a base image for each hex into a canvas. Next, the canvas listens for a mouse click. I then run a calculation to determine which hex the mouse click was closest to. My intent is to change the source of the image that the user clicked on.
I know that mapSlate.getChildByName(mapProperties[closestHex]['baseName']) is the intended hex but I can't quite get to the point of doing a .source as Flex doesn't know that the selected object is an image.
If u are sure that mapSlate.getChildByName(mapProperties[closestHex]['baseName']) is the intended hex and that it is in fact an Image, can't you cast it into Image and change the source like:
Image(mapSlate.getChildByName(
mapProperties[closestHex]['baseName'])).source = "image.png";
or
(mapSlate.getChildByName(
mapProperties[closestHex]['baseName']) as Image).source = "image.png";