How to implement Siril's MTF algorithm in GIMP plugin - plugins

I would like to implement Siril's Midtones Function Transfer algorithm in a GIMP plugin. Ideally, it would get 2 sliders (black level, midtones value) and a preview.
But I can't find a non-obsolete tutorial/example to implement a pixel operation with minimum GUI (sliders, preview...). Do you have an idea where to start ? Maybe a up-to-date example of plugin with pixel by pixel operation ? or with widget like sliders ?
# Siril's algortihm :
MTF(x;m) = ((m-1)x)/((2m-1)x-m)
# x : pixel value (float)
# m : midtones values float[0, 1]
https://free-astro.org/siril_doc-en/#Histograms
https://free-astro.org/index.php?title=Siril:Processing_tutorial
Siril is a great free software to process astrophotography, but it lacks some tools like layers, selection...

For a full-capability plugin written in C the best place is Gimp's own source. Some filters are still defined as plugins in Gimp. See here.
Otherwise you can do a quick proof-of-concept in Python, with an auto-generated dialog for the two sliders (but no preview). The python interface defines "pixel regions" that map a python list directly over the Gimp data.
You can even use Numpy.
For a Python POC:
Official Gimp-python doc is here.
Numpy link has an example script.
Large set of example scripts here.
An example of all the UI widgets here
Some hints about debugging your stuff here

Related

equivalent of the cwt (matlab) function for octave gui?

I'd like to use a Continuous wavelet transform (CWT) function in my octavegui code.
in Octave gui CWT is not available - is there equivalent .pkg to use a cwt?
fwt is available in the ltfat.pkg- but this seems to be something different than cwt.
According to the pdf from Prusa a form of a CWT is a Morlet or a mexican hat ("Continuous Wavelet Transfom – CWT (Morlet, Mexican hat, . . . ).= - is it possible to use a Morlet function in Octave? or is this something different?
any suggestions? (I am not a mathematician)
thank You
If none of these functions cover your needs, then you have two other options:
Use a c++ or java package within octave. Octave has external interfaces for both.
Use a simple python / julia / whatever scripts to perform specific calculations using your favourite wavelet package natively in that language, and use .mat converters to pass data (e.g. scipy.io.loadmat / savemat in python, and MAT.jl for julia) in and out of octave. Octave provides a 'python' function for executing python scripts for convenience (but this is no more than a nicely wrapped system call).
In any case, unfortunately that does mean you would need to know a bit of python / c++ / java respectively.
You can find a nice list of wavelet packages here.
Another thing you could try, is scilab. It is similar to octave (though not identical), and provides a wavelet package. There's also a module which allows intercommunication between octave and scilab.
Do have a look at the octave forge list first though. It's been a while, but last time I worked with wavelets I remember those covered my needs more than adequately.
PS. I did not mention Wavelab above, because their website does not mention this, and I don't know if it actually works on octave. Also, it seems a bit outdated. But in theory there's no reason why it wouldn't work, might as well give their .mex files a try if it seems relevant to you.
PS2. If something works for you, feel free to leave a comment here for future readers.

Training tesseract 4 with images instead of font

I have some questions about making tiff/box files for tesseract 4.
In TrainingTesseract 4.00 document written:
Making Box Files As with base Tesseract, there is a choice between
rendering synthetic training data from fonts, or labeling some
pre-existing images (like ancient manuscripts for example).
But it did not explain how to train with pre-existing images.
I want to train for the Persian language in tesseract 4 (lstm). I have some images from ancient manuscripts and want to train with images and texts instead of font. So I can’t use text2image command. I know that the old format box files will not work for LSTM training.
How can I make tif/box for tessearct 4 lstm then label them and
how to change tesseract commands?
Should I use other tools for generating box files (Given that Persian
language is right to left )?
Should I use fine tuning or train from Scratch?
I was struggling just like you, until I found this github repository:
https://github.com/OCR-D/ocrd-train
It will make your life super easy. All you need to do is to put your images in tif format and your text should have the same image name with extension .gt.txt. It will take care of all the rest for you. (you might need to update the Makefile according to your local machine)
Whether to train from scratch or fine-tune depends on your own language, data and the problem you are trying to solve. For me the fine tunining is what I need cause I am happy with the current performance but need to add upon it.
All the useful details you might need can be found in this answer
1) Use below command to make lstmbox:
tesseract test.tif test-lstmbox -l eng --psm 6 lstmbox
It will make a lstmbox for you but you have to correct the character in box file.
2) You require enough data for training from Scratch So I suggest fine tuning is better option.

2D multi-robot simulation libraries?

background
I'm working on a group project to simulate some consensus algorithms used by a group of independent robots to form an arbitrary shape on a 2D plane. The robots are modeled as unit disks, and all run the same algorithm. Basically, each robot can move, wait, or observe its local environment at any moment, but cannot communicate explicitly with an other robots. We'd like to find a simulation or even 2d graphics library to help us without writing too much from scratch.
Question
Can anyone recommend a simulation library meeting the requirements below, which could be used for a multi-robot 2D simulation?
I've never coded a simulation before, so it's possible some of my concerns are readily addressed by many existing libraries. However, the Mason project is the only resource I've found that seems promising so far. Unfortunately, a few of our team members are not very proficient in Java, so I'd like to find something suitable in a different language, if possible.
Requirements
* language preference (descending order): python, c++, (maybe) java
* open source/FOSS recommendations only
* Options/flags to disable simulation: We plan on running several thousand trials of randomly generated shapes against each algorithm, so for the bulk of trials we don't care about any visual representation, just data. So the simulation logic has to be decoupled from the graphics components if this makes sense.
* collision detection
* Customizable visual representations: Within a simulation, we'd like to have several views (or toggles for a single view) that present additional information about each robot like current state, the area it's currently observing etc.
For such simple graphics you can surely get away with either pyqt or wxpython.
The simulation itself should be its own python module; the GUI should just load the module, then call its "timestep" function at regular intervals (timer, GUI idle callback, etc); the step function should evolve the robot system by one small time step.
The GUI should just display the simulation state. Avoid mixing everything (display and simulation) in one module, it'll get pretty messy, plus if your simulation engine is a separate module you can then also run it directly from the command line and look at the output file.
It would be pretty easy to write a python script that reads such output file and generates commands to represent it graphically in either excel or powerpoint using win32com, in which case you don't even need pyqt or wxpython.
For the collision detection, look at pybox2d.

Use SVG plots when Publish-ing to HTML

This question was posted on Matlab Central (http://goo.gl/MkU8P) but hasn't gotten any answer. I thought someone here might have a lead.
I use publish() quite a bit to produce online class notes. It's working well but frankly, I find the PNG plots to be of awful quality. I've tried setting figureSnapMethod='antialiased' and that's a bit better but I mostly find the result fuzzy.
What would be awesome is to produce SVG plots. Is there any way to do that? I suppose it would have to involve plot2svg somehow (also from File Exchange) since SVG output seems to be only supported for Simulink models. Or perhaps someone has a better solution using some other high quality format.
before using publish you should set some options to change imageForamt. by default it is set to PNG format which is not good for reports, papers, etc. what you need is a vector graphic image, something like an eps or emf file formats. (in such case it does not matter how much you zoom in , it never becomes fuzzy or low resolution).
Any image format that your installed version of Microsoft Office can import, including 'png' , 'jpg', 'bmp',and 'tiff'. If the 'figureSnapMethod' is 'print',then you can also specify 'eps', 'epsc', 'eps2', 'ill', 'meta',and 'pdf'
for HTML output any format publishes successfully
for latex output any format publishes successfully
I suggest you to use eps, it is the best. and remember SVG is not supported in publish. ;)
you should add this part to your command:
'imageFormat','eps'

Matlab vs Aforge vs OpenCV

I am about to start a project in visual image-processing and have no had experience with Matlab, Aforge, OpenCV and was wondering if anyone had any experiences with these different software packages.
I was also wondering which of the three packages were most efficient I assume OpenCV but has anyone had any experience?
Thanks
Jamie.
The question you need to ask yourself is which is more important - your time or the computer's time. If your task is really simple, you may be able to code it up in MATLAB and have it work right off the bat. MATLAB is by far the easiest for development - a scripted language with built-in memory management, a huge array of provided functions, and a great interface for displaying and manipulating data while debugging.
On the other hand, MATLAB is at least an order of magnitude slower than compiled openCV code for many tasks. This is especially true if you use the intel performance primitives libraries.
If you know how to code in MATLAB, I would suggest writing and debugging your algorithms in that language, then porting them to c/c++ with openCV for speed. If there are only a couple of simple functions that you need to speed up, you can call c code from MATLAB, but it's hard to get this working right the first few times you try it, so you're probably better off just rewriting your finished code entirely in c/c++
First, please elaborate about your project's needs. It has the biggest impact on the choice, in addition to other factors - your general programming knowledge (If you haven't dealt with dot net but just with C++, AForge is not a good choice, for example).
Generally,
Both AForge and OpenCV has a built-in interface to .Net, and OpenCV also with C++, python, and more. Matlab might be more efficient, but if you don't have any experience with it - you should also learn its syntax. Take it into consideration.
Matlab probably has the largest variety of functions, but it is more complicated than the other projects. OpenCV and AForge themselves have some differences - see them described in this StackOverflow question/ answers.
I worked last year in two similar projects with cars on the highway. Afaik, Matlab allows to process only one picture frame at a time (surely you could elaborate an algorithm to compute a stream) but using Simulink you can process the stream directly.
On the other hand, i found AForge a lot friendlier and easier to use since you can easily adjust the processing parameters from a GUI (not so fast/easy) to do in Matlab/simulink.
I'd go for Aforge.Net. It's also fast enough if you're worrying about processing speed. (using 640x480)
If you are asking about using one of these in .net,easily you can get info by this:
1-matlab mostly used in simulation of projects not the End-prototype project; my numer : 30;
2-aforge (as I'v used in many project) if you do not need the circular process like capturing image, or recognition of something in images or ... you'll find it very good, cause it is easy to use but useful for single processes; my number : 50
3-opencv very good at speed and useful for circular processes, for example you can capture images from a webcam and Instantly cartoonize it without any delay, But not easy-to-use as aforge. I like it anyway cause of its speed and MANY functions it gives us mostly anything we need in programming; my number : 80
Dr.Taha - Tahasoft.net