Iwould like to do simple batch processing of images but I am not quite sure how to do that and what method I should use.
What I need is: I have usually 8 images (containers) in one data file. I want to tell Gwyddion to take lets say image Nr. 1, 4 and 5 and apply a set of processing steps on those (flatten, denoise, set limits of z- scale bar to e.g. -0.5 to 0.5 V) and save them all as a jpg into a predefined folder (maybe with different names for image 1, 4 and 5).
Because I already know Python a little, I thought about using this. I understood from the gwyddion homepage that I can either use Python or the Pygwy console inside gwyddion. Is there a major difference between the two possibilities?
The first problem I have is, I don't know how to get Python communicating with Gwyddion and which command prompts or Shells I would need to use (I don't know much about programming). I installed Python 2.7.5 and PyGTK (using the all in one installer).
Instead of using Python directly I tried to use the Pygwy console and I copied your code from the example "Calling process module and export" into Pygwy console and it worked.
The only things I still need are the commands of how to e.g. set the z-scale to certain values for several containers of a dataset. I thought all process modules were listed in this pygwy documentation but I can't figure out which process modules belong to which processes in the gwyddion visual interface.
Could you please help me with that?
If you think, I should better use Python itself rather than Pygwy console to do that or another method, please feel free to say so.
If you are comfortable with Pygwy and see no problems in using Python scripts inside Gwyddion, you should do it. But if you're not, one can always write a standalone Python script to run from command line including Gwydion libraries.
thank you very much for your very quick reply. I had a look at the last pygwy example. My problem is that I don't know what I have to actually type into the console to get what I want. E.g. for rescaling Z-axis, I don't know which command I have to use.
I tried this one: gwy_color_axis_new_with_range(1, -0.5, 0.5)
but it did not work.
I don't really understand the code. For example, I don't know if all processed containers are saved as a png file and into which location. It would be great if someone could explain me the syntax of the code a little more in detail (in relatively easy words :-)?
I tried to run the pygwy example that Vinicius suggested (Iteration over opened files on ). It does change all containers in one data file but it does not export the changed images as png files. It just opens the export window for one of the containers and when I press ok, it does not even save the image somewhere. Do you think I have those troubles because I am running a 64 bit windows version?
Hello, the example script works for me in Linux. I'm not sure what the scripts gets as the working directory on MS Windows though. Did you try to put an absolute output file path there instead of just "exported_png_%d.png"?
thank you for your reply. I just tried what you suggested and set instead of "exported_png%d.png" a path "C:\Gwyddion.png" I don't know if I did that correctly but I still have the same problems as before.
However, I have tried both the last example "Iteration over opened files" and "Calling process module and export" from the website and both did not seem to work correctly for me.
I copied the code exactly like it is from the website into my pygwy console. When I ran the "Calling process module and export" code on one of my files, the last image (image=datafield is that correct?) of my container (I think the container consists of all images that belong are usually stored in one of my AFM files is that correct?) was processed and exported as png in the same location as the original AFM file is stored. It also stored the fixed file and the text files for the one dimensional autocorrelation function etc. in the same folder so these things work. However, I thought the code would process and export the currently selected image as png but it always only processes and saves the last image of the container and displays all images of the container in the GUI (all images get ticked in the data browser).
It is similar with the "Iteration over opened files" code. It processes all images of the container. However, it opens the export dialog for one of the images in the container (always the same image but not the last one) and when I click ok, it does not even save the image as png in the folder. What I would like to have is, that the code only processes the image that I have currently selected and exports it as a jpg for example.
I guess what I describe is not what those codes should do? Do you have any good ideas what I could try?
I thought about trying to do the same on a 32 bit windows os because I thought it might be a compatibility issue? I also used the PyGTK all in one installer so I thought there might be a problem.
On -class.html it says the ColorAxis.set_range min and max need to be floats but it does not work (for Ruler as well).
Do you know what's the problem there or do you think I should use some other command to do that? I would also like to be able to tell gwyddion to run the set_range command on e.g. datafields 3 and 5 of a container like here:
I also have another question regarding gwydump. You suggested me to use gwydump to better understand how gwyddion works. I'm not sure if I really understood what it is good for. I assume I can open a file with gwyddion, process a datafield using the GUI and save the file and then print it in a textual form to see what command lines were created due to my manual processing, is that correct? If that's the case, can I then use those command lines in pygwy console?
You can (in principle) but still don't want to do this with specific instances, i.e. specific ruler or axis widgets in a specific data window. This would mean locating the specific data window and then the specific widget inside (which is possible though not completely trivial) and setting the values. The result of such exercise would be a temporary change of the range because that's not how it is controlled.
If you don't understand what classes and instances are please read some object oriented programming introduction. I can explain how things are organised in Gwyddion but can't provide a general programming guide...
Unless you write a module with its own graphical user interface, you do not interact with the widgets directly. Only work with data and other values in the container; occasionally use of data browser functions may be necessary/useful.
Concerning gwydump, it shows the structure of a gwy file (and to a certain extent its contents). Let's say you want to see what happens in the container when you set the colour range to fixed. So you do this in the colour range tool, save the modified file and use gwydump to inspect it.
I also tried to use gwydump. I copied the exe file into the same directory where gwyddion was installed and I also added the directory to my system's path but when I tried to start gwydump, the PC attempts to start it, but then nothing happens. Do you think it can be run on a 64 bit OS?
Concerning gwydump, it is a command-line program. So I'm not sure if `nothing happens' doesn't just mean that you run it from the GUI, so the program runs, prints some help (since it didn't get any arguments) and happily terminates. Or it really does not work. But certainly the executable on
gwyddion.net is 32bit so it only works with 32bit installation of Gwyddion (in whateverbit version of the OS).
I am trying to write a stand-alone python script that could take .ibw files as input, and from them, create a png image corresponding to the height retrace (what I see in the gwyddion application.) This is because I would like to generate previews for large numbers of files.
I also got the source code for gwyddion - I haven't used C in a long time and I was wondering what is the best way to run it using an IDE? I'd be potentially interested in contributing since, I'm working on a project for processing a wide range of materials science related data. I just signed up for the gwyddion-devel list but have not received the confirmation email yet.
The confirmation e-mail for mailing list subscription should be sent automatically and immediately. I have just tested it and it works for me. Please check your spam folder (or, if you subscribed a GMail address, try some other account because GMail's spam filters have a large false positive rate).
Where 0 is the Height Retrace, and 1 the Amplitude Retrace etc. The image previews are the same as what I see in gwyddion so this will work great for processing large numbers of .ibw files. I can get the data field title for each file as well. gwyutils also has
This method allows the full control of the look of the exported image. It does the same as saving the file as whatever.png from the GUI, with all the settings used there the last time. But you can modify any of the settings beforehand as
On a Unix-like system (such as OS X) the files are located exactly as I wrote, do not look elsewhere. You do not need the source code. Of course, you can also study the module source code if you wish -- it is modules/file/imgexport.c.
I am able to use the values in settings to get keys, and so far, for all images they provide the presets. This happens even though, when I open the files in gwyddion using the app, one is approximately 3 micrometer square, and the other twice as large. I'm looking to automate a process where when files are uploaded, they will provide an image preview and then at least the size of the image. So I can check them manually with imageexport, but this won't work for an automated process. My goal was to create the png images, and then just a text caption which states the dimensions of the x and y and range of z.
3a8082e126