I am displaying an image in figure window in MATLAB using following code.
im = imread('Image02.tif');
processAndDisplayImage(im);
hImage = image(im);
set(hImage,'ButtonDownFcn',#clickInImage);
But problem is that the third line above makes the image changed for some reason I don't know. Is there any way to get image handle without the modification?
UPDATE: Resolved the problem. Please refer to my answer below.
The image graphical command cannot change the image. I can only guess that it shows the image in a way you don't want it. Inspect the range of the image -
max(im(:));
and also the type:
class(im);
and try to figure out what is wrong
Perhaps you could modify processAndDisplayImage so that it returns a handle to the displayed image as an output variable?
Instead of
hImage = image(im);
I used following to solve my problem.
[hImage hfig ha] = imhandles(gcf);
But I still don't understand image command does to the actual image displayed on figure.
Related
I'm using the print function in MATLAB to write images of plots, something like that
print(figure(1),'-dpng','-r300',filename);
But apparently the images are not overwritten, and the original images stay. I was using saveas before, which seems to overwrite the images, but print gives me more output options. Any ideas?
UPDATE: I ended up deleting the files before the printing with a different function.
You can use this:
im = frame2im(getframe(gcf,rec)); %Grabs image of plot as an image
imsave(im, filename); %save image
That syntax may not be 100%, its a while since I've used it.
Also be aware that this isn't perfect - I remember having issues with it grabbing a grey border around the edge of the plot. Also, I think the image may be based on a matlab screenshot.... just something to be aware of
Saving figures in matlab is rather troublesome, especially if the saved image should look like the original figure.
For myself i found the solution in using export_fig.
It's one of the most downloaded fileexchange files - maybe you should give it a try:
http://www.mathworks.de/matlabcentral/fileexchange/23629-export-fig
A small introduction to export_fig can be found at:
https://github.com/ojwoodford/export_fig/blob/master/README.md
I am having trouble saving renders to an output file (using Maxscript). I use the following code in my script:
`render camera:$VRayCam002 frame:1 outputfile:"testscript.tif"`
When I run the code, I can see the scene render in the frame buffer, but the saved file, 'testscript.tif' is blank, i.e. the image is all black.
Any ideas what I may be doing wrong?
Thanks,
Figured out the problem. Apparently, while doing things pertaining to the render scene dialog settings in MAXScript, the actual dialog should be closed. See here from MAXScript help documentation.
With the dialog closed, the image saves properly
Also be sure to set
rendSaveFile =true and rendOutputFilename = "whatevername"
i have a code which gives several images as ouput and i want to set all these images in particular axes in GUI in matlab. I'm trying to make a GUI of the code.
For eg.
figure,imshow(s1);
figure,imshow(s2);
figure,imshow(s2&s1);
and i want to set the output image of first command in, say axes3, output image of second command in axes4 and similarly last output image in axes5.
Although i know i need to use
set(handles.axes...)
command but i don't know the exact syntax on how to make the image be shown in particular axes.
Please give explain on how to make this happen with any suitable example. Thanks in advance.
One line solution (for each image) is to set the axis as the parent of the image within the imshow command;
imshow(image_Data,'Parent',handles.axes1)
There should be no need to open the additional figure windows ( assuming the axes are with the gui...)
So specifically for the question above:
imshow(s1,'Parent',handles.axes3);
imshow(s2,'Parent',handles.axes4);
imshow(s2&s1,'Parent',handles.axes5);
First you should create an axes box in your gui, then in tag section get a name i.e. (original) and finaly in editor when you want to use it code something like this
A = imread (Path);
axes(handles.original);
imshow(A);
I hope to help you...
As we know, we can use WriteFrame to save bitmap to file in wic.
Here in the method WriteFrame,we can see a parameter ID2D1Bitmap object.When I use
m_d2dContext->CreateBitmapFromDxgiSurface(surface.Get(),&bitmapProperties,&myBitmap);
and then pass myBitmap to WriteFrame,I can't get the bitmap,it show me a black image.
But when I use
m_d2dContext->CreateBitmapFromWicBitmap(pB.Get(), &m_Bitmap);
and pass m_Bitmap to WriteFrame, I can get the correct bitmap in the image file.
Why this happen?
Can anyone help. Thank you.
I'm trying to add and if needed by user, change the image from a widget in python.
I'm using Glade with gtk2+, python 2.7.3, and these is what I'm doing
image = gtk.Image()
image.set_from_file("MyImagePath.png")
image.show()
button = App.get_object('buttonExample')
button.add(image)
and this is what I get when try to change the image
GtkWarning: Attempting to add a widget with type GtkImage to a
GtkAspectFrame, but as a GtkBin subclass a GtkAspectFrame can only
contain one widget at a time; it already contains a widget of type
GtkImage
The image is loaded correctly as expected, but if I change the input path for image, I wish I could change the button image, but this is not what I'm getting.
I tried to use gtk.Image.clear(), but it says I cannot use it on a button (maybe im just messing things around)
Is there a good way to load and reload images to a button?
Thx
You either have to remove the old image from the button before adding a new one (the error message is pretty straightforward about this), or you could try changing the current image:
button.get_child().set_from_file("MyImagePath.png")
This was exactly what I needed. I used the clear in the image as you said and also cleaned the button image, as follows:
App.get_object('buttonExample').remove(image)
image.clear()
Thank you very much for you help!