xuebinqin / U-2-Net

The code for our newly accepted paper in Pattern Recognition 2020: "U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection."
Apache License 2.0
8.49k stars 1.46k forks source link

Why does the output image change? #250

Open ashikrafi opened 3 years ago

ashikrafi commented 3 years ago

Hi Qin,

Great work indeed. Anyway, can you tell me the reason for the color change in the output image

Thank you

ashikrafi commented 3 years ago

Hi @xuebinqin,

I look forward to hearing from you.

Thank you

xuebinqin commented 3 years ago

Sorry, I don't know why you got this error. But our model only output a probability map. You can concatenate your original rgb image with the BINARIZED one-channel probability map to formulate a FOUR Channel RGB-Alpha image. This RGB-alpha image shouldn't have any differences on the foreground pixels' color w.r.t the original image. I guess you may probably forget about BINARIZING the probability map ?

On Fri, Aug 27, 2021 at 11:16 PM Md Ashikur Rahman @.***> wrote:

Hi @xuebinqin https://github.com/xuebinqin,

I look forward to hearing from you.

Thank you

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xuebinqin/U-2-Net/issues/250#issuecomment-907421886, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORMC34GRPLALH4V7GDDT67QCVANCNFSM5C3HGLDQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage:https://webdocs.cs.ualberta.ca/~xuebin/

ethardoth commented 2 years ago

Hi @ashikrafi,

It looks to me that the reason for your problem might be that your original image has embedded color profile. It needs to be the same for the output image in order for colors to be displayed in the way you expect. You can check Color management and ICC profile topics.

I would recommend reading the image and ICC profile info using Pillow. Here's an example on how to do it in Python:

original_image = Image.open(image_path).convert('RGB') color_profile = original_image.info.get('icc_profile') ... final_image.save(out_path, icc_profile=color_profile)

Best regards.