Issue with composite -stereo on 6.7.8

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?".
GPI
Posts: 9
Joined: 2017-11-29T08:10:43-07:00
Authentication code: 1152

Issue with composite -stereo on 6.7.8

Post by GPI »

Hello,

I am currently trying to figure out an issue I encounter when using the "composite -stereo" command.

The goal is to merge 2 grayscale tiff files into one where one of the image is in one color while the other is in a different color. It will help me to easily find out the discrepancies between the two images.

On a server, I have ImageMagick 6.2.8 installed and the command below is working fine.
composite -stereo one.tif two.tif output.tif
Output.tif is the resulting image with color so the discrepancy are immediately visible.

On a new RedHat 7 server with ImageMagick 6.7.8 installed the command below is generating only a gray scale image.
composite -stereo 0 one.tif two.tif output.tif
The two images are displayed but since only in gray color, it is harder to tell the différences between both.

The application 6.2.8 installed on the RH7 server provide proper results but since I had to find the rpm (and dependencies) on a third party website, I cannot fully trust the application.
Sources of application 6.2.8 found on the Sourceforge website do not compile on the target server.

Could you please let me know whether this is a known issue or is it by design ? Is there a work around I could use with v6.7.8 to get a colored anaglyph from two grayscale tif ?

Many thanks in advance for your help.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Issue with composite -stereo on 6.7.8

Post by snibgo »

If you link to one.tif and two.tif, we can test it.

Perhaps the problem is that recent IM converts the output to the colorspace of the first input. As the input is gray, it will be in grayspace, so perhaps IM makes the output the same. The cure may be "-colorspace sRGB" after the inputs.
snibgo's IM pages: im.snibgo.com
GPI
Posts: 9
Joined: 2017-11-29T08:10:43-07:00
Authentication code: 1152

Re: Issue with composite -stereo on 6.7.8

Post by GPI »

Thanks for your feedback. I have tried to add the option "-colorspace sRGB" without success.

The files have been uploaded on the link below: https://www.sendspace.com/file/6zz8r3

There is file one and two along with the result when the command is used with v6.2.8 and with v6.7.8.
Last edited by GPI on 2017-12-01T07:26:03-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with composite -stereo on 6.7.8

Post by fmw42 »

composite is a very old and limited tool. You might be better off using the more flexible convert ... -stereo syntax so that you can add -colorspace sRGB and other commands as well as parenthesis processing. See http://www.imagemagick.org/script/comma ... php#stereo
GPI
Posts: 9
Joined: 2017-11-29T08:10:43-07:00
Authentication code: 1152

Re: Issue with composite -stereo on 6.7.8

Post by GPI »

Thanks for your help as well. The option "-stereo" is the one I am trying to use but it does no seem to be an option for the "convert" command.

When I try, I get a message "convert: unrecognized option `-stereo' @ error/convert.c/ConvertImageCommand/2761"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with composite -stereo on 6.7.8

Post by fmw42 »

You are correct. I get the same message. So the documentation at http://www.imagemagick.org/script/comma ... ptions.php for -stereo needs to be modified to say that it is a composite option, unless there is a bug and it should work for convert.

In the mean time, you can use convert to process your two input image to change them to -colorspace sRGB and pipe to composite:

Code: Select all

convert image1 image2 -colorspace sRGB MIFF:- | composite -stereo +10+0 - stereoimage
There is probably no compose equivalent to stereo for convert, since I do not see it listed at http://www.imagemagick.org/script/compose.php
GPI
Posts: 9
Joined: 2017-11-29T08:10:43-07:00
Authentication code: 1152

Re: Issue with composite -stereo on 6.7.8

Post by GPI »

Thanks for the lead.
However, it produce the same result as the command "composite -stereo 0 image1 image2 stereoimage", meaning a black and white tiff file.
GPI
Posts: 9
Joined: 2017-11-29T08:10:43-07:00
Authentication code: 1152

Re: Issue with composite -stereo on 6.7.8

Post by GPI »

After some more tries, I found that using a .jpg file instead of a .tif file as the output is working fine.

So the command below is giving me the proper result with a colored jpg image:

Code: Select all

composite -stereo 0 one.tif two.tif output.jpg
I will see how it fits with the other parts of my environment and close the topic if the modification is acceptable.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with composite -stereo on 6.7.8

Post by fmw42 »

This works fine for me on IM 6.9.9.24 Q16 Mac OSX.

Code: Select all

composite -stereo +10+0 logo: logo: logo.tif
So it might be an issue with your old version of ImageMagick.
GPI
Posts: 9
Joined: 2017-11-29T08:10:43-07:00
Authentication code: 1152

Re: Issue with composite -stereo on 6.7.8

Post by GPI »

Just installed v6.9.9-24 on my CentOS but still no luck with my files.

With the logo: as a source, I agree that it works fine. Difference would be that the colorspace of the logo: is sRGB while the one from my tif files is Gray.

I believe that using .jpg as the type of the result file will work for me so I will probably leave it this way.

No sure if I should change the title as "solved" however since the original issue remain :) I'll come back from time to time to see if an answer comes up and close the ticket once the file sharing link above has expired.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with composite -stereo on 6.7.8

Post by fmw42 »

This works fine for me on IM 6.9.9.24 Q16 Mac OSX.

Code: Select all

convert logo: -colorspace gray logog.tif
composite -stereo +10+0 logog.tif logog.tif result.tif
Perhaps you should post your two input tif images. If the tif files have transparency or multipage or multilayer, then that might be the cause of your issue.
GPI
Posts: 9
Joined: 2017-11-29T08:10:43-07:00
Authentication code: 1152

Re: Issue with composite -stereo on 6.7.8

Post by GPI »

Please find below a link to one of the file I am using.

https://www.sendspace.com/file/6zz8r3

The issue can be reproduced using the command:

Code: Select all

composite -stereo +20+0 one.tif one.tif result.tif
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Issue with composite -stereo on 6.7.8

Post by fmw42 »

This could be considered a bug.

The problem is that you have a bilevel (black/white) image. The stereo command works, but keeps the output as grayscale. You need to convert to grayscale or color first. This works for me on IM 6.9.9.25 Q16 Mac OSX.

Code: Select all

convert -quiet one.tif one.tif -type truecolor miff:- | composite -stereo +20+0 - result.tif
as does

Code: Select all

convert -quiet one.tif one.tif -type grayscale miff:- | composite -stereo +20+0 - result.tif
GPI
Posts: 9
Joined: 2017-11-29T08:10:43-07:00
Authentication code: 1152

Re: Issue with composite -stereo on 6.7.8

Post by GPI »

Many thanks for your help. While the commands do not work with the default CentOS/RHEL 7 version 6.7.8, it works fine with version 6.9.9.24.

At least I can compile the official version of ImageMagick and use this one instead.

Thanks for the time you took to answer my query.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Issue with composite -stereo on 6.7.8

Post by magick »

Add -compress none to your command-line. In the mean-time we'll add a patch to fix the problem you reported.
Post Reply