how to: filtering / building category for black and white photos?

Started by spiff, October 05, 2021, 04:47:45 PM

Previous topic - Next topic

spiff

Hello,

i search for a way to config my filter or / and build a category to filter for black and white fotos. I am grateful for help. Regards Björn

Mario

What do you consider a black and white photo?

A file with only 1 BPP? A file where every pixel, after analysis, is one of 1 or 0? An image where every pixel has the same components in the RGB color space? Or roughly the same components? Maybe its the color profile that produces a monochromatic or black and white result...?

This is quite complex to solve and is no metadata tag or variable / feature in IMatch for this. This would require something like, from the top of my head, a color conversion into HSL and then using some heuristics or thresholds to put the image into the color or black-and-white or monochrome buckets. Doable, I'm sure you can find tools for this, e.g., Image Magick or similar.

I recommend marking the images you consider grayscale by hand (place them into a category or add a keywords).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ubacher

If you convert from RAW to jpg using Adobe Camera Raw you get
XMP::crs\ConvertToGrayscale set to true.
You can filter for this.

Another way is to filter for ICC_Profile::Header\16\ColorSpaceData GRAY

spiff

Thank you. I can not find them or are at least not selectable in the imtach field selectioin?

spiff


Mario

As I've tried to explain, there is no criteria for "black & white" photos...
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

loweskid

Quote from: ubacher on October 05, 2021, 07:29:02 PM
If you convert from RAW to jpg using Adobe Camera Raw you get
XMP::crs\ConvertToGrayscale set to true.
You can filter for this.

Another way is to filter for ICC_Profile::Header\16\ColorSpaceData GRAY

The problem is that images could be monochrome and still be in RGB mode, but desaturated.  The agency I submit to (Alamy) will accept monochrome images but they have to be RGB, they won't accept greyscale.

spiff

A software which is able to scan pictures and detect and assign faces is highly developed. Why should this software not able to scan pictures and recognize if for each dot in picture values vor R,G,B are identical it must be a BW photo altough the picture is in RGB mode? Where is the problem?

Mario

IMatch could do that. But that would be really slow.

Either IMatch would have to do this when ingesting file, so it has to do it only once.
This would slow-down the ingest considerably and would also require a long-running conversion phase for every existing database when this feature is introduced.

Or, IMatch would have to do it every time your data-driven category is updated. Or you run a special "find all monochrome images".
And cache the result so it does not do it again (unless files are modified).

Consider a database with 100,000 files.
Say it takes only 1 second per file  to determine if it is monochrome. It probably takes more.
This means 100,000 seconds or about 27 hours. A PC with 10 cores can bring that down to maybe 2 to 3 hours, at 100% load.

It's doable. But is it feasible? How many users will ever need this?

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

thrinn

Quote from: spiff on October 07, 2021, 11:46:57 AM
A software which is able to scan pictures and detect and assign faces is highly developed. Why should this software not able to scan pictures and recognize if for each dot in picture values vor R,G,B are identical it must be a BW photo altough the picture is in RGB mode? Where is the problem?
There may be additional cases where a picture is recognized as "B&W" by humans, but not by the machine: For example, I have some old scanned B&W photos which were scanned in color mode. And while they are visually gray scale photos, the numerical values of the dots are not always exactly identical. So the condition "RGB value must represent a shade of grey" might not work well enough, dependent on the source and file format.

If you want to classify pictures already in your database, you could also try to use the "Search for similar colors" command. I tested it on some B&W pictures, and the result was quite promising. If you accept to have to mark B&W manually by some category or whatever, this might speed up your workflow.
Thorsten
Win 10 / 64, IMatch 2018, IMA

spiff

It´s on you. If it would be in it´s behavior like face recognition it could be accepted (let imatch work a night and it´s done for the DB). If it really would need more time than face recognition, i can´t estimate if its worth it. Maybe you are interested yourself and test what you can reach.

Yes, if you start from scratch you can just give the pictures a sign. But if you already have thousands of pictures a slow working command once also could be fine? Maybe thrinns proposal is the way to go...

Mario

Have you tried the visual query functions yet? See also thrinn's answer.

When you use a monochrome image with the "similar colors" feature (all other options off), you should get (mostly) monochrome images.
The maximum number of results is 1,000 so you may want to use 10 or 100 originals and then select them and put them into a collection or a category.
Filter these images out and search again. This should allow you to find all monochrome images quickly.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

spiff

Hi, i used the imatch search thrinn and you suggested me. It works surprisingly well. Thank you. I suppose the search uses cache data? Is it possible to optimize this search for B/W searching a bit or are we going back to the discussion where we were already?

Mario

This search is based on a advanced histogram. No optimization required.
See above. Cost. Performance. Feature request etc.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook