5

I've been tasked with finding a way to automatically crop and colour adjust product images. The images are on a white-ish background with somewhat inconsistent lighting.

Manually, we'd use photoshop to adjust the levels to force the top-left pixel to be white, which would apply the changes to the whole image. Photoshop can do this automatically.

I've just started learning image magick and I've got it to automatically crop the images, which has turned out pretty nice. I've also done -contrast-stretch 0%x75% which has worked somewhat well to brighten up the image.

I'm wondering if image magick (or something similarly automatable) can do something similar to what photoshop does. What I've got now works fairly well, but not as well as what photoshop does. Any ideas?

1
  • This is an awesome question! I'd like to know how to do this automatically as well. However, in my experience, it's best to use one image to (manually) determine the correct white balance and then apply that to all images. May 23, 2020 at 22:58

2 Answers 2

2

I actually found this a few days later and forgot to answer my question.

Assuming you're running from a .bat file:

for /f %%i in ('magick %1 -format "%%[pixel:p{10,10}]" info:') do set COLOUR=%%i

Gets the colour of the pixel at 10,10 from the top left.

magick %1 -level-colors black,%COLOUR% %1

Shifts that colour to white.

@hedgie made a good point, but if you're using natural, inconsistent lighting like we are this can provide pretty good results.

0

My doubt is that the appropriate response is - truly, ImageMagick is comparable to for any individual element it offers as an immediate other option.

Different graphical change calculations are basically recorded nowadays and there is each opportunity that you get in open source programming is utilizing similar procedures behind it.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.