Imagemagick or similar for scripted image enhancement - python

I found the following algorithm to work fairly well for enhancement of various images of whiteboards, etc:
duplicate the layer, make sure the top layer is active
(gaussian)blur the new layer. You shouldn't be able to read the text anymore.
set the layer mode to dodge
invert the layer
I tried it out in gimp and it looks promising. I'd like to try it en-masse for a large number of images and make it available as a command line tool.
I realize I can script gimp, but that feels too heavy for this purpose. Imagemagick seems ideal for this, but I don't know if I can do the layering with it.
So the question is:
Is there a way to script imagemagick to do the above algorithm without the use of a temporary file?
Is there a reasonable alternative library/tool that can be integrated with Python?

There is a ImageMagick script for whiteboard cleanup here - http://www.fmwconcepts.com/imagemagick/whiteboard/index.php

Related

OCR using custom font in python

I am trying to detect text from a video game. The game uses a custom font, and I have the font files available to me. The text characters in the game are not distorted and are clearly visible. I am aware that similar questions have been asked already, but it seems to me that the previously presented solutions might be outdated.
What would be the 2023 way of detecting the text and bounding boxes in images using python?
I tried to do it in Tesseract, but the font is not included in the pre-trained model, hence Tesseract performs poorly.
In principle, I could train Tesseract to use the custom font. The problem seems quite straightforward to me: create a custom .traineddata file and tell tesseract to use it when detecting. However, it seems like the Tesseract trainer by Anyline is not available anymore and the Qt-box-editor used in some tutorials to do it manually is not maintained anymore.
The fact that my search for something that in my mind should be quite straightforward and fully automated (use custom font file to create labeled text images, train tesseract on them, use the trained model) only leads to outdated and quite lengthy instructions that involve many manual steps, indicates to me that either I am trying to use Tesseract for something it was not meant to do or that I am missing some tool that everyone else is using.

python image unified transform

I looking for a way to transform a Image into a another one.
The tool from GIMP work perfectly for my task: "Unified Transform Tool"
But is there a way to do it with a python lib? Like openCV or PIL?
My Goal is it to add images to mockup photos and I have to do it automaticly.
I don't know the GIMP technique, but it looks like a "Scale Rotate Translate" kind of thing which you can do in Python with wand.
You can do the same thing in the Terminal with ImageMagick. Tutorial and examples here.

How can I make a bayer image and become a debayer again? (demosaicing)

My goal is to blur the picture a bit using a bilinear debayer.
This is to embody the dirty image of the VHS days.
As a graphic major, I tried to reproduce it with various graphic tools, but did not get the desired quality result.
I want that subtle feeling of faded haze when scanned with a scanner.
I decided to emulate a camera sensor.
The process I envisioned is this:
I convert the tiff,targa.png.jpg format image I made into a bayer format image. I want to restore the original image by debayering it again with a bilinear algorithm.
The reason for the bilinear method is that it degrades most gently and strongly.
The link below is the image change according to the algorithm.
https://www.dpreview.com/forums/post/63514167
I'm not a programmer at all, but I've tried something on my own to get what I want.
https://codegolf.stackexchange.com/questions/86410/reverse-bayer-filter-of-an-image
I succeeded in making an image of the Bayer pattern using the coding here.
And I tried debayering by running the debayer source code downloaded from other places, but it failed because the extension was not supported.
So you can change demoasic(debayer) in various ways
I got a program called darkable and raw therapy and tried to convert it, but these programs could only recognize raw files.
Even the algorithms provided by both programs were so good that it was hard to get the impression that the image was degraded.
How do I make what I want?
What can I look for? I really want to make this.
Please let me know which way I should go.

PNG to PGM conversion without quality loss

So, I have a PNG image file like the following example, and I need it to be converted into PGM format.
I'm using Ubuntu and Python, so any of terminal or Python tools would suit just fine. And there sure is a plenty of ways to do this: using ImageMagick convert command or pngtopam package or Python PIL library, etc.
But the point is, the quality of the image is essential in my case, and all of those failed in keeping it, always ending up with:
No need to mention this is totally not what I want to see. And the interesting thing is that when I tried to convert the same image into PGM manually using GIMP, it turned out quite well, looking exactly the way I'd like it to, i.e. the same as the PNG one.
So, that means it is possible to get a PGM image in fine quality after all, and now I'd really appreciate if someone can tell me how do I do that using terminal/Python tools. I guess, there should be some ImageMagick option that does the trick, it's just that I'm not aware of any.
You lost the antialiasing, which is conveyed via the alpha channel. To preserve it, use:
convert in.png -flatten out.pgm
Without -flatten, convert simply deletes the alpha channel; with -flatten it composites the input image against the background color, which is white by default.
Here are the results, magnified 10x so you can see what's going on:
Not flattened:
Flattened:

Python - Identifying/Processing an Image

I'm looking in to learning about processing and handling images with Python. I'm experimenting with searching the inside of an image for a specific picture. For example, this picture has two images in it that are the same;
In Python, how would I go about detecting which two images are the same?
I would recommend you to take a look at OpenCV and PIL, if you want to implement simple (or complex) algorithms on your own.
Furthermore you can integrate OpenCV with PIL and also numpy, which makes it a really powerful tool for this kind of jobs.

Categories

Resources