Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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--
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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...
- var theIndex = 256;
...so the code looks like that?
- var theIndex = 256;
- theIndex--
;
Copy link to clipboard
Copied
Just test the code in its current form.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
is it because of the color?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now