How to Automate Selection of Black Bands

New Here ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

I need to batch process images that are flanked by black areas. These black areas may be top and bottom, or left and right. They vary in proportion, but regardless I need to delete these black areas without selecting any black within the central image. Shown here are two images that typical of what I am starting with. The idea is to crop down to just the central image and eliminate the black boundary, without selecting incidental black in the central image.

 

What is the best sequence of actions to accomplish this? Thank you!

 

glissando.jpgebnat.jpg.

TOPICS
Actions and scripting, Import and export, Mac

Views

360

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

Try to insert a Levels layer with parameters 128-1-255 -> 0-255. Execute the Trim command for Top Left Pixel Color. Then delete the Levels layer.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Wouldn't be result the same after trimming without using adjustment layer?

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Wouldn't.

There's noise on black

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Oh okay, I assumed bands are 100% black, but maybe while posting they lost their uniformity.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

I understand what you're saying, but would this also cut any black pixels from the central img, too?

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 09, 2021 Mar 09, 2021

Copy link to clipboard

Copied

Have you tried it yourself?

 

If at any border of the "useful picture" there is at least a pixel with a level greater than 128, then the "Trim" will not go deeper into the image further than this pixel. You can change the value of 128 (the first parameter for Levels), for example, by setting the value 20.

 

For your first image, 11 is enough, for the second 13. Otherwise, there will be remnants of "black".

 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

I just tested and it works to record single step action then to batch process. The only requirement is that you must have always black color in top left or bottom right corner, in other words all your images must be either as example 1 or as example 2.

 

Update: based on @r-bin suggestion which seems to work to avoid tiny black border, record additional step with black point set to 20 in Levels adjustment layer as shown on screenshot below, it does work for tested single image, test with random chosen image or try to find consistency like single pixel black border then record step to delete that border, you can use conditional actions to check orientation of image.

levels modified.jpg

 

After recording single step action run File > Scripts > Image Processor and check Run Action then choose proper set and action in section 4.

run action trim during batch.jpg

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines