Command to save images in TIFF format rather than TIC format
I’m using the built in camera plugin for Ximea on ITOM. In the tutorial, the command saveTIC saves the acquired images in the TIC format. I’m wondering if there is a command to save the images in TIFF format instead?
Thank you!
Comments (12)
-
-
Where did you find the saveTIC command, since I would say, that this is a spelling mistake or an error in any tutorial or documentation. Please give me a hint where you found it, such that we can potentially correct this.
The right algorithm, implemented in the dataObjectIO plugin and generally denoted as filter is called saveTiff.
Please open the Plugin Help Viewer in the Help menu of itom and search for saveTiff. Then you get a description of this algorithm.
The traditional, generic way to call this algorithm is
import itom img = itom.dataObject([100, 100], "uint16") itom.filter("saveTiff", img, "C:/temp/myimg.tiff", "gray16")
From the current master or the upcoming itom 4.2 on, these algorithms are also directly accessible and its parameters are displayed in the calltips and auto completion, if they are called by this new, recommended way:
import itom img = itom.dataObject([100, 100], "uint16") itom.algorithms.saveTiff(img, "C:/temp/myimg.tiff", "gray16") # or itom.algorithms.saveTiff(img, filename="C:/temp/myimg.tiff", palette="gray16")
Other image formats, like jpg, png, pgm, ppm, bmp… also also supported by other algorithms in the dataObjectIO plugin. See the Plugin Help Viewer, too.
Furthermore, methods like itom.filterHelp can also be used to obtain a list of algorithms or a description of an algorithm in the command line of itom.
-
reporter Thank you for your help. Also, I found the saveTIC command in this demo file https://bitbucket.org/itom/itom/src/master/demo/itom/basics/demo_CameraAndImages.py . The saveTIC is near the image saving code section.
-
reporter Hello, so I got image saving code working but I can only save 1 data object by using the suggested itom.filter method (see below). At the moment, it can only save ‘d' but I want to save “result” into the tiff file. The purpose of this code is to see many images together to see what happens to the fringes of an interferometer experiment (similar to what happens in the ximea cam app when you click record loop).
#image saving code for j in range(0,10): camera.acquire() camera.getVal(d) result.append(d.copy()) #save list of image angle_value = (i+1)*(-directedAngleInc) filter("saveTiff", d, "E:/William Nguyen/angle"+str(angle_value)+"tiff", "gray16")
-
Hi William,
the saveTiff algorithm of itom is not able to save a stack of images in one tiff file. Maybe, there are other python packages, that can do this (http://soft-matter.github.io/pims/v0.5/tiff_stack.html). You can usually pass a dataObject to any argument that accepts an numpy.ndarray-like object. Even, if only a real np.ndarray is accepted, you can easily convert
any dataObject to a numpy array bynpArray = np.array(myDataObject, copy=False)
Usually, the numpy constructor makes a deep copy of data, pass copy=False to make a shallow copy (only possible if data types are compatible.
Another possibility would be to stack all your images into a 3d-dataObject, e.g. by
myDObjStack = dataObject.dstack(result) # if result is a sequence of dataObjects of same shape and type
Then, you can save this stack as an idc file, and reload it using loadIDC if required. The itom 2d plot also accepts such an image stack.
If this is the case, you will find a spin box in the toolbar of the plot that allows scrolling through the different image planes. Additionally, there
are tools in the toolbar of the plot to show a cross cut as 1D plot along the z-direction at the x,y coordinate of the mouse click or it is also
possible to show a 2d projection along a line, indicated by the mouse, an the z-direction. These features can maybe help to visually analzye your
interferograms in detail.Just one example:
myStack = dataObject.rand([100, 1000, 1000], 'float32') myStack.axisScales=(1, 0.02, 0.02) myStack.axisUnits=("", "nm", "nm") myStack.setTag("title", "Demo object") plot2(myStack, "itom2dqwtplot") # the plot class name can be omitted if the default plot class for 2d plots is properly set.
Highlighted are the special buttons in the toolbar and you can also see, that units, scalings, titles etc. are automatically considered in the plot.
If I select the z-stack button and click somewhere on the canvas, a 1d linecut over all 100 z-layers is displayed:
Cheers
Marc
-
reporter Perfect thank you. Tried this today and it worked perfectly for my set up
-
You can also add such Plots in a GUI for you measurenment App. Take a Look into zur new Demos docu https://itom.bitbucket.io/latest/docs/11_demos/itom/ui/demo_embedded2DLinePlot.html#sphx-glr-11-demos-itom-ui-demo-embedded2dlineplot-py https://itom.bitbucket.io/latest/docs/11_demos/itom/basics/demo_measurement.html#sphx-glr-11-demos-itom-basics-demo-measurement-py
-
reporter I’m looking at the pims package to stack my images as a TIFF file (http://soft-matter.github.io/pims/v0.5/tiff_stack.html). I installed this in itom. My approach right now is to save the individual image as a single tiff using:
itom.algorithms.saveTiff(img, filename="C:/temp/myimg.tiff", palette="gray16")
Then I will stack them using the pims package. However, the algorithms.saveTiff returned an error of:
Runtimeerror: cv: inwrite exited with false!
-
reporter I think this might be a new problem with itom 4.2? I don’t recall having this error with this particular line when I used itom 4.1 a week ago
-
Hi William,
are you sure that the directory exists? I tried to save an image with the itom 4.2 setup and only got your exception if the directory (here: C:/temp) does not exist. The error message has to be improved → task for me.
-
I created an issue in the plugins repository to enhance the error message: https://bitbucket.org/itom/plugins/issues/18/savetiff-savepng-raise-a-strange-exception
-
The issue in the dataObjectIO plugin is fixed by https://bitbucket.org/itom/plugins/commits/148d433970e6bff00a553eee86916d4af3ecee47
- Log in to comment
The itom dataObject can be saved in different images types which are in the dataObjectIO Plugin https://itom.bitbucket.io/plugindoc/plugins/algorithms/dataObjectIO.html