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

which horizontal array of pixels is the first to be composed entirely of white pixels?

Explorer ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

What would be the fastest way to detect which horizontal array of pixels is the first to be composed entirely of white pixels?

TOPICS
Actions and scripting

Views

899

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
Enthusiast ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

If you want best performance, maybe you could use SDK and write custom filter in C++

This should be fastest 😄 There are some premade examples. Filter should be able read pixels in certain layer because filter change pixel values in certain layer.

Anyway C++ is pretty hard and most people prefer scripting in JavaScript.

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
Explorer ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

What would be the approach to take with javascript? I can't find a way to retrieve a pixels information. 

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
Enthusiast ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Simple but not very effecient way in JS.

Make rectangular selection

Copy merged bitmap

Paste it into new document

Read histogram data of this document

Repeat with different selection if you need.

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
Explorer ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

I understand. Is there a way you can provide a simple example of how to make use the histogram data? Looking at the programming index, it looks like it is an array of 255 members, but not much more information is given.

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
Enthusiast ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Each array item contains number how many pixels has this level of luminosity.

item 0 = black pixels

item 255 = white pixels

Or opposite. I am not sure.

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
Explorer ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

I see. hmm. This sounds like its going to get a bit complicated.  Less complicated, though, i bet, than learning c++. Thanks man, i'm going to give it a shot and see what comes of it.

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
Enthusiast ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

You can use Color sampler for individual pixels. No new document needed. But this could be very slow with large images.

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
Advocate ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

I can confirm, item 0 is black, item 255 is white.

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
Advocate ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Actually, the histogram is read from the active channels.

Therefore, it should be possible to turn the selection in its own channel, hide all other channels, read out the histogram, analyze the data, do what's needed, dump the channel and make the other channels visible again.

Depending on the kind of pictures, it would be possible to start with a bigger selection and make it smaller only when the conditions are given.

As stated, it may be a bit time-consuming, but it should be quite straightforward.

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
Enthusiast ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Yes. You can invert selection and create new most top black layer from inverted selection.

So every pixel outside this selection will be in "item 0"

You can access into R G B channels directly without creating something new. I am not sure if this works for other channels.

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
Explorer ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Do you guys know if there is a way to easily access the histogram's mean?  that way i can have it fire at a certain range?

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
Advocate ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

What you get from Photoshop as histogram is, as already stated, an array of 256 elements, representing the number of pixels for a given grey value.

That's what you have to build your analysis and interpretation on. For that you are on your own, but JavaScript is powerful enough to let you implement any algorithm you need. You might have to find the algorithms, but for that, there is good literature around.

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
Explorer ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Thank you all very much for all your help. I did find an alternate tread that helps you figure out the mean in the histogram:

How do you get Histogram Mean Value?

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
Contributor ,
Apr 14, 2017 Apr 14, 2017

Copy link to clipboard

Copied

Bonjour

You can use Mike Hale's selectColorRange function (scObj) HERE

//SelectionLigneBlanche.jsx

var blanc = new SolidColor();

blanc.rgb["hexValue"] =  "ffffff"          // "829fb1"       // "0000ff";

for( var f = 0; f < activeDocument.artLayers.length; f++ )

{

   activeDocument.activeLayer = activeDocument.artLayers;

   selectColorRange(blanc);

   // activeDocument.selection.clear();

   //activeDocument.selection.deselect();

}

function selectColorRange(scObj)  // by Mike Hale - merci a lui :

{

    var desc = new ActionDescriptor();

    desc.putInteger( charIDToTypeID( "Fzns" ), 0 );

    var cDesc = new ActionDescriptor();

    cDesc.putDouble( charIDToTypeID( "Rd  " ), scObj.rgb.red);

    cDesc.putDouble( charIDToTypeID( "Grn " ), scObj.rgb.green);

    cDesc.putDouble( charIDToTypeID( "Bl  " ), scObj.rgb.blue );

    desc.putObject( charIDToTypeID( "Mnm " ), charIDToTypeID( "RGBC" ), cDesc );

    desc.putObject( charIDToTypeID( "Mxm " ), charIDToTypeID( "RGBC" ), cDesc );

    executeAction( charIDToTypeID( "ClrR" ), desc, DialogModes.NO );

}

var ligneBlanc = activeDocument.selection.bounds[2];

var largeur = activeDocument.width;

if (ligneBlanc=largeur)

{

  //alert(activeDocument.selection.bounds[2]);

  alert("Hauteur = " + activeDocument.selection.bounds[1]);

  alert("Largeur = " + activeDocument.selection.bounds[2]);

}

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
Advocate ,
Apr 14, 2017 Apr 14, 2017

Copy link to clipboard

Copied

A little nitpicking (but needed, otherwise, the script would fail):

the line

if (ligneBlanc=largeur)

should read

if (ligneBlanc==largeur)

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
Contributor ,
Apr 14, 2017 Apr 14, 2017

Copy link to clipboard

Copied

LATEST

Yes !

I hesitated !!!

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