I would like to draw an image into another image with Wand (an ImageMagick binding for Python). The source image should totally replace the destination image (at given position).
I can use:
destinationImage.composite_channel(channel='all_channels', image=sourceImage, operator='replace', left=leftPosition, top=topPosition)
But I was wondering if there is a simple or faster solution.
But I was wondering if there is a simple or faster solution.
Not really. In the scope of wand, this would be one of the fastest methods. For simplicity, your already doing everything on one line of code. Perhaps you can reduce this with Image.composite.
destinationImage.composite(sourceImage, leftPosition, topPosition)
But your now compromising the readability of your current solution. Having the full command with channel='all_channels' & operator='replace' kwargs will help you in the long run. Think about revisiting the code in a year.
destinationImage.composite(sourceImage, leftPosition, topPosition)
# versus
destinationImage.composite_channel(channel='all_channels',
image=sourceImage,
operator='replace',
left=leftPosition,
top=topPosition)
Right away, without hitting the API docs, you know the second option is replacing destination with a source image across all channels. Those facts are hidden, or assumed, in the first variation.
Related
Keep in mind that this is a challenge, I am not expecting a full answer, just a bit of help.
On the image archived you are able to see a complex captcha that I am attempting to solve using code.
The captcha has a column for # and another composed of a random string.
The captcha itself is actually identifying which string row has the different color in it, once you identify that then you can input the # of that string row.
For the image below the string row #4. has a smaller portion of str colored differently, and #4 is the correct answer.
How could I solve this programmatically?
I thought of using AI but I think that is overkill, I should be able to do this with OpenCV.
Note: The background is also a random image, it can be anything.
Fortuntely, the foreground is very noticeable and clear making it easy to ignore the background with code
I am mostly researching possible methods of solving this captcha, fortunately I think I'm on the right path, which involves using OpenCV, but I'm not sure which functionalities of OpenCV I should use for this.
The challenge requires the app to return an integer, in this case it is the # of the correct 'messed' up string.
I get a problem when handling images taken from cell phones.
Image sample:
So, get ghosting especially for the question number area.
I think the reason is a little joggle when press the shutter.
Is there any way to remove the ghosting thus question number area will look more clear?
There is another worse one:
Actually, I find some image denoising functions like cv2.fastNlMeansDenoisingColored(), and it indeed works well upon some images.
Unfortunately, doesn't work for the above two images.
Env: Python3.6.5 Opencv:3.4.0
Thanks.
Wesley
I have an image pair.
What I require is to report changes b/w them(which I'm able to do).
The program also shows changes where there is the big black patch in Image1. While it is definitely a change, I require such changes(where there is no information(black patch) in one of the images) to be ignored.
For eg, in the given pair, only the hexagon should be shown as a change. Thus, I need to locate the coordinates of either the patch or image sans the patch.
I came across an approach in this answer.
How can I achieve this in Matlab? The approach works great, but I am having trouble finding the functions corresponding to the cv2 functions in Matlab (particularly cv2.approxpolyDP() and cv2.arclength().Tried using regionprops but to no avail.
Is there any other way too, other than the one in the linked approach
PS:I am new to Matlab.
I'm using Python 2.7, PyGTK 2.24, and PyGST (Gstreamer).
To ensure smooth playback from one clip to another (without a blink), I combined all the clips I needed into one larger video. This lets me seek to the exact place I need in code. One of the clips is like a "fill-in", which should loop whenever one of the other clips is not playing.
However, to make my code easier and more streamlined, I want to use segments to define the various clips within the larger video. Then, at the end of each segment (I know there is a segment end event), I seek to the fill-in clip. When I need another clip, I just seek to that segment.
My question is, how exactly do I create these segments? I'm guessing that would be the event_new_new_segment(), but I am not sure. Can I create multiple clips to seek with using this function? Is there another I should use. Are there any gotchas to this method of seeking in my video that I should be aware of?
Second, how do I seek to that segement?
Thank you!
Looks like only GstElement's can generate NEWSEGMENT events, you can't simply attach it to an existing element. The closest thing you could do if not using Python, would be creating a single shot or periodic GstClockID or and use gst_clock_id_wait_async until the clock time hit. But the problem is, GstClockID is not wrapped in PyGst.
I think I'm actually working on some similar problem. Some kind of solution I'm using now, is gluing video streams in real time with gnonlin. The good side: seems to work, didn't have time to thoroughly test it yet. Bad side: poorly documented and buggy. These sources from the flumotion project (and the comments inside!) were very, very helpful to me for understanding how to make the whole thing work.
I want to transform photos in python to look like this:
taken from doctype.com
I will use it in django, PIL is installed.
How can I achieve this?
This is a combination of several subtle effects. It starts by a nonlinear deformation, and then a tasteful drop shadow is added. There's also a small border. I'd start by drawing one straight, vertical line on the above picture, and then seeing how you would transform to that from the original picture. Then, apply that transformation to the whole photo, add some drop shadow, and figure out what else is left...
I've had a bit better luck with ImageMagick when it comes to more complex transformations. You would have to install it separately and though there is a python library it doesn't appear well documented so I've just used command line calls.
Here is a good tutorial on warping image:
And another tutorial on general use
The drop shadow is probably just a second image which is composited with the first image.