Identify if flipping is needed and flip

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
pski
Posts: 10
Joined: 2016-07-27T13:05:07-07:00
Authentication code: 1151

Identify if flipping is needed and flip

Post by pski »

I have two tifs that are similar. What happens during normal processing of the original is it has gotten the alpha channel removed and some functions have been applied to the image. Unfortunately, to my dismay despite asking them to fix it, the processing that is done "sometimes" flips the image and rotates it. What I'm trying to do is figure out the most efficient and best way to identify if a flip is needed since these images are generally multi-gigbyte files. Below is the input and the output in a case where the image was flipped (I shrunk them down from the 1.5GB original):

Original: https://www.dropbox.com/s/yk3td3xizxvr1 ... l.tif?dl=0
Flipped: https://www.dropbox.com/s/jzbodrpw68xcp ... d.tif?dl=0

To get the corrected image I'd need to run the following:

Code: Select all

convert UpsideDownModified.tif -rotate 180 -flop Corrected.tif
I'm using "ImageMagick 6.8.9-8 Q16 x64 2014-08-26" on Windows 10.
pski
Posts: 10
Joined: 2016-07-27T13:05:07-07:00
Authentication code: 1151

Re: Identify if flipping is needed and flip

Post by pski »

My original thought would be to extract the alpha channel from the original, and then take all the black pixels from the "possibly flipped" and make them alpha, compare the alpha channels, And if it's within some reasonable variance (since the output may have black pixels that I care about that are now identified as alpha) then don't flip otherwise do flip. It just seems like there would be a better way to answer this question
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Identify if flipping is needed and flip

Post by snibgo »

pski wrote:... trying to do is figure out the most efficient and best way to identify if a flip is needed ...
From your samples, I don't know what visual feature determines whether a flip is needed.
snibgo's IM pages: im.snibgo.com
pski
Posts: 10
Joined: 2016-07-27T13:05:07-07:00
Authentication code: 1151

Re: Identify if flipping is needed and flip

Post by pski »

I updated the photos with larger versions (1200 pixels). Towards the pixel coordinates 437,37 in the original, there's a blue circle (it's water) and in the flipped version, it's the black hole at the bottom This is also a screenshot showing what I mean: http://screencast.com/t/R4AN5RJECaZ
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Identify if flipping is needed and flip

Post by fmw42 »

If all your images do not have such a unique marker and in the same relative location, then I do not see how that helps.

I, too, do not see any way to identify whether the image needs flipping, unless you have some key marker that you know where it should be in the original image.
Post Reply