Page 1 of 2
compose blending different with cropped image, why?
Posted: 2012-02-07T11:02:09-07:00
by fragileandys
I have an image, and an almost exact copy of the same image that I am compose blending together with ModulusSubtract into one image:
Code: Select all
convert -page 185x230 img.jpg -page +0 copy.png -background none -compose ModulusSubtract -flatten out.png
However if I crop the copy.png image and try the same compose blending applying the offset (after finding it with -subimage-search), the final image doesnt appear to have the same blending applied:
Code: Select all
convert -page 185x230 img.jpg -page +4+5 copyCrop.png -background none -compose ModulusSubtract -flatten out.png
Why would I get different results just because one image is cropped? I am positive my offset of +4+5 is correct, as the images align perfectly.
Re: compose blending different with cropped image, why?
Posted: 2012-02-07T11:24:09-07:00
by fmw42
Try removing the virtual-canvas created with the png image by adding +repage just before the output of your first command.
Re: compose blending different with cropped image, why?
Posted: 2012-02-07T11:43:34-07:00
by fragileandys
The +repage doesnt seem to have any effect.
Let me specify that the first command is the one that is working how I want it to and would like to replicate with the cropped image, comparing it to the original.
Re: compose blending different with cropped image, why?
Posted: 2012-02-07T13:16:55-07:00
by fmw42
where did you get the image copyCrop.png, if you used crop on a png, then it will have a virtual canvas. Try removing the virtual canvas with +repage on the cropped image. Or specify how you got copyCrop.png so we can see what is going on.
Re: compose blending different with cropped image, why?
Posted: 2012-02-07T13:25:32-07:00
by fragileandys
I didn't use IM to crop the image. I am on a mac, I opened the copy.png with the built-in 'preview' application, cropped it and saved it out from there.
Re: compose blending different with cropped image, why?
Posted: 2012-02-07T13:31:49-07:00
by fmw42
At this point I suggest you post links to your various input and output images, so others can review and test with them.
If you cannot post these images somewhere and link to them, then post the results of
convert copyCrop.png -verbose info:
Re: compose blending different with cropped image, why?
Posted: 2012-02-07T13:38:42-07:00
by fragileandys
Thanks for all your help fmw42!!
I just cropped the same image using photoshop and saving is as a ping and it worked fine. So 'preview' must do something strange to the image before it saves.
Re: compose blending different with cropped image, why?
Posted: 2012-02-07T13:45:30-07:00
by fmw42
fragileandys wrote:Thanks for all your help fmw42!!
I just cropped the same image using photoshop and saving is as a ping and it worked fine. So 'preview' must do something strange to the image before it saves.
Probably keeps the virtual-canvas, which can be removed by adding +repage after reading in the cropped image in your command line.
Re: compose blending different with cropped image, why?
Posted: 2012-02-07T13:56:13-07:00
by fragileandys
haha, thanks man, i'll mess around with that +repage more
Re: compose blending different with cropped image, why?
Posted: 2012-02-07T22:10:56-07:00
by anthony
The +repage should be immediately after the -crop operation
PNG will save 'virtual canvas' information so doin it as two steps will not help.
photoshop and gimp does not preserve this information. IM does because it can be useful in later image processing stages.
Re: compose blending different with cropped image, why?
Posted: 2012-02-08T09:25:01-07:00
by fragileandys
Anthony
So if the image is cropped in an outside program that saves the virtual canvas (the default 'preview' on a Mac), there's nothing I can do about it?
Re: compose blending different with cropped image, why?
Posted: 2012-02-08T10:56:09-07:00
by fmw42
fragileandys wrote:Anthony
So if the image is cropped in an outside program that saves the virtual canvas (the default 'preview' on a Mac), there's nothing I can do about it?
No, if the virtual-canvas is saved (and I don't know if Preview does that), all you need to do is add +repage after reading in your cropped image.
convert croppedimage.png +repage ....
PNG saves a virtual canvas, jpg does not.
You can check if your image has a virtual-canvas, by looking at the verbose info.
convert image -verbose info:
Look for the line near the bottom that is "page geometry" and see if it is the same size and zero offset as the image. If not, then there is a virtual canvas.
Or from identify
convert logo: -gravity center -crop 50x50%+0+0 logo.png
identify logo.png
logo.png PNG
320x240 640x480+160+120 8-bit PseudoClass 226c 14.5KB 0.000u 0:00.000
The blue is the actual image size. The red is the virtual canvas.
P.S. On my Mac OSX Snow Leopard, I tried to crop an image with Preview. But it does not look like it saves the virtual canvas for me. So I am puzzled why you are having this problem.
Re: compose blending different with cropped image, why?
Posted: 2012-02-08T15:09:01-07:00
by fragileandys
It doesnt appear that there is a virtual canvas applied to it. The 'Page Geometry' is the same as the 'identify' output.
What I'm doing is tiling a watermark across an image at .5% opacity. Then comparing the original image with the watermarked image to show the watermark.
If I crop the watermarked image with photoshop I am able to use -subimage-search and the output images from that show me the same difference I can see when when comparing the full images (i can see the watermark).
However when I crop using 'preview' then use -subimage-search, the outputted comparison image does not show me the watermark. So preview is doing something differently when cropping than photoshop is doing.
Re: compose blending different with cropped image, why?
Posted: 2012-02-08T15:24:00-07:00
by fmw42
Is it possible to provide links to your images so that others can test. Also what was your exact command line for the compare in both cases? Note that the resulting x,y coordinates from compare refer to the upper left corner of the subsection (small image) in relation to the upper left corner of the larger image (not the center of the small image). What version of IM are you using?
Re: compose blending different with cropped image, why?
Posted: 2012-02-08T17:10:37-07:00
by fragileandys
First off, this image is not my own. I do not own it and do not claim to have taken the photo.
photobucket album password: imtesting
The original image:
http://i28.photobucket.com/albums/c242/ ... /image.jpg
The watermarked image:
http://i28.photobucket.com/albums/c242/ ... m/copy.png
make a random crop of the watermarked image with photoshop saved as crop1.png then:
Code: Select all
compare -metric RMSE -subimage-search image.jpg crop1.png out.png
the out-0.png is:
http://i28.photobucket.com/albums/c242/ ... /out-0.png
make a random crop of the watermarked image with mac's default 'preview' saved as crop2.png then:
Code: Select all
compare -metric RMSE -subimage-search image.jpg crop2.png out.png
the out-0.png is:
http://i28.photobucket.com/albums/c242/ ... ut-0-1.png