• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to approuch detecting jpg file content (rendered masks)...

Participant ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

I want to make a function that analyses a 3D render's set of mask jpg files. One important part of the analysis is the mask content. Basically, a jpg file with parts black, parts white. An empty mask would be 100% black for example.

The main goal is to detect if a mask is empty or not, but I would also prefer to find a way to calculate the percentage of white a mask has. This way, when all masks are analysed, I could for example calculate what percentage of image is missing masks.

I would like to detect empty masks even without opening the jpg file (for performance reasons).

Maybe by filesize, taking a predefined dimension into account, but this is not fail save.

And the mask percentage can not be calculated by dimension and filesize alone.

I know you can open files windowless, but that has many limitations as far as I can remember, but you can read the dimensions of the jpg this way, and is much quicker than windowed. At the time, I could not figure out how to read meta data on a jpg file directly for information like the dimensions, so if anyone knows how, that would also be very usefull!

 

For calculating the mask percentage.. Not sure how to get there. Maybe using histogram data in some way? Using bounding box dimensions is useless I think. Anyone any ideas?

TOPICS
Actions and scripting

Views

316

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 Expert ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

This is something that's an easy project for Mathematica.  I would do it there.  Use the EXIF data for dimensions and misc information then analize the file.   Easy stuff.  

ICC programmer and developer, Photographer, artist and color management expert, Print standards and process expert.

Votes

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
Community Expert ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

They seem to want it done via magic without even opening the file to read data I'm sure some meta data is available from the file system. However I do not believe a mathematician could calculate the percent black from EXIF data if such data existed.  I'm sure some EXIF like meta data  will be available because the file type is a jepeg.   Their jpeg files are rendered 3D mask not Camera jpeg files with camera exif data.  How would a mathematician be able to compute percent  black from EXIF data  dimensions,  exposure, lens etc information.

JJMack

Votes

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
Community Expert ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

I think you may have misread my reply. I said to get the image dimensions from the EXIF data (but that's also easy to get from the file) and us the software Mathematica to do the number crunching.   I have used that for decades and it is a very good tool for image analysis 

ICC programmer and developer, Photographer, artist and color management expert, Print standards and process expert.

Votes

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
Community Expert ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

If the Jpeg  are gray scale mask You may be able to use Photoshop  histograms the see percentage of the image is 100% back however the histogram is not  in the jpeg file meta data and the Images pixels are data conpressed in the jpeg file. How do expect tobe able to get the percent black without decoding the jpeg image, which would not be the actual mask encode because of jpeg lossy compression?

JJMack

Votes

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
Participant ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

You are correct, I would expect I need to open the jpg file to read the image content itself.

Detecting empty masks (100% black jpg's) it would be doable if I have the dimensions and filesize, so for this alone I hope not to have to open the file.

But is it even posible to read EXIF data from the JSX enviroment?

 

The masks are normally fully white or black. But antialiasing and small objects cause grayscale pixels. Not sure if it needs to be that precise to account for that. For perfect accuracy, yes.. a single mid-gray pixel would count as half.

Maybe if I read the histogram data or I go take a look at "software Mathematica".

Votes

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
Community Expert ,
Nov 18, 2021 Nov 18, 2021

Copy link to clipboard

Copied

Would your jpeg files even have EXIF data.  What good would having Cameta information be for your what you want?  Youe file system hasn a lof of information avout you file avaiable.  wigi would inude EXIF dmatadat if you file hevet it.  All jpef files have EXIF mete data. Look at the details  windows file exploter shows for your jpeg files

image.pngimage.pngimage.pngimage.png

JJMack

Votes

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
Participant ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

I checked the meta/exif data and the jpg's have at least the dimension information.

I also tried some online exif data viewers and a command line "exiftool" to output all the jpg's information...

Image Width, Image Height, Bits Per Sample, Color Components, Image Size, Megapixels.

I found a working script to read this meta/exif data from JSX...

 

#target photoshop;
ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript"); 
var s = File.openDialog("Please select JPG file.","JPG File:*.jpg"); 
var file = new XMPFile(File(s).fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_READ);    
var xmp = file.getXMP();
if( xmp.doesPropertyExist(XMPConst.NS_EXIF, "PixelXDimension" ) ) {
    var x= xmp.getProperty(XMPConst.NS_EXIF, "PixelXDimension" );
    var y= xmp.getProperty(XMPConst.NS_EXIF, "PixelYDimension" );
    alert("X = " + x + " Y = " + y );
}else{
    alert("This files does not have EXIF dimensions");
    }

This works perfectly, but it was mentioned it would not work when people rotated the image in the OS, but thats not an issue for my purposes, that never happens.

The code request the width dimension property with the string "PixelXDimension" for example.

All the exif tools do not show this specific string. To retreive additional exif information I need to know the Strings I need to use.

For example, if I want to retreive the "bits per sample", what would the corresponding string be?

 

For the percentage calculation, I will try something out with the histogram data.

Votes

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
Community Expert ,
Nov 19, 2021 Nov 19, 2021

Copy link to clipboard

Copied

LATEST

 Your do not need to have EXIF data to get canvas size and if thers is EXIF data information . EXIF Data doses not have information like how many  pixels are black.

 

You can not process all the Pixels in the image a pixels at a time with a script in a short period of time.  Retrieve  Histogram information about a black selection would be most likely what you need to do. You need to open the jpeg and select the black pixels.

JJMack

Votes

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