Page 1 of 2
Get difference between two images, transperency result.
Posted: 2012-02-17T16:23:20-07:00
by suryx
I couldnt find article about my subject from the google or forum ImageMagick.
- = ?
This result should be transperency with color yellow(alpha) (so like it on 1st image).
ps. I was reading from the tutorial, but from the tutorial difference was like image no transperency...
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T16:28:48-07:00
by fmw42
Not really sure what you want. Can you explain further? Do you have an example showing your desired output. If we knew exactly what you want for the output we can probably help further.
Have you tried using compare to find differences. See
http://www.imagemagick.org/script/compare.php and
http://www.imagemagick.org/Usage/compare/
Once you find where the differences are, you can convert the color to transparent via -threshold and/or -fuzz XX% -transparent somecolor
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T16:46:13-07:00
by suryx
I dont wanna ussing compare to find a difference.. Must be command convert.
If we got a result, we could add transperency result to the image
so give as merged layers as one image :
..
You understand?
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T17:42:04-07:00
by fmw42
No, I don't really understand, sorry. I thought you were trying to highlight the difference between two input images in an output image. If that is not the case, please clarify the process that you desire to be implemented in IM.
I do not understand how you got the second image from the first.
You can always add transparency to an image by making a mask (by whatever means you desire) and putting it into the alpha channel of the image. See -compose copy_opacity -composite.
http://www.imagemagick.org/Usage/compose/#copyopacity
If your first image already has transparency and you want to flatten it against some background color, then use
convert image -background yellow -flatten result
However, as your first image is jpg, it has no transparency. So you need to create a mask for the alpha channel or use -fuzz XX% -transparent somecolor to create an alpha channel with transparency as you desire. Then use the command above to flatten it on yellow to highlight the former transparent vs non-transparent regions.
Is this what you want?
Input:
# line 1 - read input image
# lines 2,3,4 - create mask with center 80% gray and rest white
# line 5 - delete images from line 2 and 3 and put the mask image into the alpha channel of the input
# line 6 - flatten the image with the alpha channel over a yellow background.
convert 47817946.jpg \
\( -clone 0 -fill white -colorize 100% \) \
\( -clone 0 -fill gray -colorize 100% -resize 80%x80% \) \
\( -clone 1 -clone 2 -gravity center -compose over -composite \) \
-delete 1,2 -alpha off -compose copy_opacity -composite \
-compose over -background yellow -flatten \
47817946_tmp1.jpg
Result:
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:02:44-07:00
by suryx
Example here:
Please example about command?
Ps. I have bad language English, i couldnt write so many.. I did fiqured this picture.
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:05:59-07:00
by fmw42
OK, I see. You want to subtract the images to get the difference color and size. Can you post your two input images as separate images? That way I can try some IM commands to do that.
Or try
convert image1 image2 +swap -compose minus -composite -fuzz 10% -trim result
You would be better off if your input images were not jpg (or converted from jpg to other better formats) as subtracting them is going to produce differences where you don't want them due to jpg compression. You need to start with some uncompressed format, such as png.
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:09:01-07:00
by suryx
fmw42 wrote:OK, I see. You want to subtract the images to get the difference color and size. Can you post your two input images as separate images? That way I can try some IM commands to do that.
That's sure. I wanna get this result&image gradient which placed on the wallpaper grass.
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:12:57-07:00
by fmw42
Please note that background removal is hard. In your case, all you are going to get is the color difference. That will not maintain your original color due to the transparency. You will not be able to extract the transparency, I suspect, unless you already know the color.
see
http://www.imagemagick.org/Usage/masking/#bg_remove
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:21:22-07:00
by suryx
I was trying a type command "convert image1 image2 +swap -compose minus -composite -fuzz 10% -trim result" as you asked.
So that's wrong ;/ Should be that contains alpha..
I am reading.. I will back.
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:24:13-07:00
by fmw42
You have your images backwards. Remove the +swap or use
convert bgwithoverlayed.jpg 47817946.jpg +swap -compose minus -composite -fuzz 10% -trim +repage result.png
This works for me though the result is not what you would like. You can even add -auto-level to stretch the brightness to full dynamic range.
convert bgwithoverlayed.jpg 47817946.jpg +swap -compose minus -composite -fuzz 10% -trim +repage -auto-level result.png
But you will not get both the color and transparency. All you will get is the difference in color. You cannot extract the transparency, I suspect, unless you already know the color.
Furthermore, as your images are png converted to jpg, you have compressed them and will lose quality on your recovery due to the compression.
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:28:48-07:00
by suryx
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:37:33-07:00
by fmw42
Yes, sorry, I forgot you had them above. But see my last post above yours. You have a problem that is most likely not solvable without more information and you cannot use jpg format because it is compressed and loses quality.
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:44:27-07:00
by suryx
fmw42 wrote:Yes, sorry, I forgot you had them above. But see my last post above yours. You have a problem that is most likely not solvable without more information and you cannot use jpg format because it is compressed and loses quality.
I am always using a format PNG and max quality. Try download at link :
http://hotfile.com/dl/146880342/5286cbb/imageK.zip.html
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:47:24-07:00
by fmw42
suryx wrote:fmw42 wrote:Yes, sorry, I forgot you had them above. But see my last post above yours. You have a problem that is most likely not solvable without more information and you cannot use jpg format because it is compressed and loses quality.
I am always using a format PNG and max quality. Try download at link :
http://hotfile.com/dl/146880342/5286cbb/imageK.zip.html
Your first images got uploaded as png converted to jpg (or a jpg suffix was added).
I tried your PNG images and got a red difference in color.
Your problem is not solvable without more information because it involves transparency as well as color differences. Again see
http://www.imagemagick.org/Usage/masking/#bg_remove and
http://www.imagemagick.org/Usage/maskin ... background
Background removal is very very hard to do.
Sorry I don't have any further ideas. Perhaps some one else on the forum might have other ideas or comments.
Re: Get difference between two images, transperency result.
Posted: 2012-02-17T18:57:52-07:00
by suryx
My first solution was just gone,because i have enough for find solution from ImageMagick. and lost many times.
I have second solution about making program with language c#. Because i know the algorithm, how program should working.
Thanks for many posts.