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

Selecting the brightest pixels

Explorer ,
Sep 07, 2014 Sep 07, 2014

Hello

Is it possible to write a script that finds brightest pixel or pixels (if there are more of them at the same brightness) in an active layer and selects them?

if there is an easier way to do that, (without writing a script) please tell me how...

TOPICS
Actions and scripting
8.4K
Translate
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 ,
Oct 12, 2014 Oct 12, 2014

How many instances of the word "while" can you find in the code?

The stuff in the round brackets after "while" defines the condition, the stuff in the curly brackets defines what is to be done so long as the condition is met.

Translate
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 ,
Oct 13, 2014 Oct 13, 2014

I found only one instance of the word "while".

Can you please tell me what you mean by saying ""theIndex" was reduced by 1".  What does number one indicate?

Translate
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 ,
Oct 13, 2014 Oct 13, 2014

You are familiar with subtraction?

Edit:

theIndex starts being 255 – each time the while clause iterates (the operations therein are performed) the number gets smaller by one as indicated by the line 

theIndex--

Translate
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 ,
Oct 13, 2014 Oct 13, 2014

So these two "--" hyphens mean that the number will get smaller? And please tell me why do you say the index starts being 255... Because in the code i see it starts at 256?

i dont think im familiar with subtraction When it come to writing codes.... I know what "subtract" means in english though

Translate
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 ,
Oct 13, 2014 Oct 13, 2014
So these two "--" hyphens mean that the number will get smaller?

a-- amounts to the same as a = a - 1

The code has been amended, in the original version it started at 255.

Translate
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 ,
Oct 13, 2014 Oct 13, 2014

So the options are

• starting ""theIndex" at 256 and subtracting at the beginning instead of the end of the while-clause or

• adding 1 to "theIndex" when using it in "applyThreshold"

Which of these two options will make script work faster? Or it makes no difference?

subtracting at the beginning instead of the end of the while-clause

Please tell me what you mean? Do you mean that i should put the Index-- straight after the line...

  1. var theIndex = 256;

...so the code looks like that?

  1. var theIndex = 256
  2. theIndex--

Translate
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 ,
Oct 13, 2014 Oct 13, 2014

Just test the code in its current form.

Translate
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 ,
Oct 14, 2014 Oct 14, 2014

im afraid to tell you, but the script is acting weird...i tested the script and that is what i got.. in the first image we can see the pixels script selects...image 2 - we see the very first value that opens up the brightest pixels, it is - 54. image 3 - we see which pixels the following value 53 open up... and if we compare these two values with the pixels script finds we can see that there is something wrong...Seems like the script still adds extra pixels. but those pixel are not from the following value (53).. it is like between 54 and 53...

Untitled-1.jpgUntitled-2.jpgUntitled-3.jpg

Translate
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 ,
Oct 15, 2014 Oct 15, 2014

is it because of the color?

Translate
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 ,
Oct 16, 2014 Oct 16, 2014

I am done with this Script as my (superficial) testing seemed to reveal no problems with 8bit images.

The operation works on the composite Channel so the individual RGB Channels may provide different results.

If you want to improve the Script go ahead.

Regards,

Pfaffenbichler

Translate
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 ,
Oct 16, 2014 Oct 16, 2014
LATEST

Do you know what is the best and the quickest way to learn scripting? I want to learn, but i need a good teacher. It can be a good book, or video tutorials... or just a website... And how did you learn it yourself?

Thanks

Translate
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 ,
Sep 18, 2014 Sep 18, 2014

Some of the images you posted are inconvenient to me because of the loading time and because they are displayed downscaled in my browser – please post the screenshots individually and when you talk about code please post it, not just a screenshot of it.

Translate
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 ,
Sep 23, 2014 Sep 23, 2014

why don't you just use a "levels" adjustment layer ontop of the layer you need to select the brightest pixels from?

1. add levels adjustment layer ontop of the layer that you need to select the brightest pixels from

2. in the levels panel, pull the middle slider far to the right, but not all the way

3. pull the left slider just a bit to the left

now your image should be black, except for the bright pixels. You can tweak this to your needs by slightly moving those sliders again

4. merge the adjutsment layer with the layer below (your brightest pixel layer)

5. using the magic wand, select anywhere that is dark (black pixels)

6. invert your selection, and you now have the brightest pixles selected

I tried this on your "bubbles" image and it worked fine

Translate
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 ,
Sep 23, 2014 Sep 23, 2014

Boo Radley thank for your method. The problem is that im trying to make it work either as an action or, if it's not posssible , as a script.

Translate
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 ,
Sep 27, 2014 Sep 27, 2014

The pasted code was posted wrong again, the three spaces were changed to two spaces, I corrected that and the posted code seems to work properly.

So as far as I am concerned the issue is closed.

Translate
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 ,
Sep 28, 2014 Sep 28, 2014

First of all, thank you very much for such an incredible work. based on my skills, i would've taken a year to write such script. I mean it. I appreciate that so much. Just one little issue i have encountered. i wonder if it is possible to fix it. If you have a little more time please see the images. I tested the script and learned that it selects more pixels than the very brightest. In other words, it includes pixels that are less as bright as the brightests..

i reduced exposure to make sure the difference is clearly visible...


Edit: we can see in the pictures that the brightest value is 14. But the script has also selected values which are lower than 14.

small waves1.jpgsmall waves2.jpgsmall waves3.jpgsmall waves4.jpgsmall waves5.jpg

Translate
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