Author Topic: Position editor snap grid, // and how to extract dominant gray value?  (Read 482 times)

Hello,

I would like to use the newly released Float2 / Position or Transform Offset editors on an exposed parameter, and keep the possibility to use Steps, or any custom function on it.
The draggable controllers override the values and don't listen to Steps or to my function.
SoI can't have my draggable controller to "snap" on pre-set points.
Unless I could extract the value I generated with the controller, and round it?
I am using the float2 on a Transform 2D node by the way.

I am looking for a work around to this, any idea?

The first work around that I found brings me to a second question I'm also stuck on:

I would need to extract the dominant gray scale value on the totality of my input pixels, so say the dominant is 255 (white) I would define 255 = x, y and I'd have what I want, but I am stuck at extracting this value and exploiting it.

I tried watching some Pixel Processor videos as I thought it would be the key to extracting this value, but it doesn't seem like I can then input it and use it in a function?

What do you think?
Thank you!
Hope I'm being clear don't hesitate if you'd like more informations
Last Edit: December 07, 2017, 07:54:57 am

Hello, here is an update on this case, if someone else is having this struggle I could have my Position draggable controller to snap on X and Y integer values using a pixel processor, the Crop Grayscale one, tehen you can edit the value however you want and it will take it in consideration!

As of the second question, I'd love to find a way to do that I guess the processing time would be shorter.
Thanks

extracting the dominant value with a pixel processor is possible, but very tedious to set up.
should quantizing your image values be an option, you should definitely do it, as it will reduce the amount of checks to the quantized level number.

the brute force way means having an if check for every possible value in individual pixel processors that will put out a 1 / 0 mask depending on exact matches for that value. then you average the pixel value of all those masks (down-res to a single pixel) and get the maximum (max node in a pixel processor) result of all the averages. you will have to set your format to 32f, otherwise most of your average values will be 0 instead of 0.x .
once you have your maximum average you will have to compare that to all the averaged values and multiply the matching mask with your original image to isolate all pixels with the dominant color.

the last step will be to dilate that color onto the entire image which can be done by offsetting the pixel in all 8 directions by 1 pixel and combining the results via max again. depending on your image size you will have to repeat that process quite a few times.

note the multiplication by 9 there - this is the third time im doing the dilation process here so i can use that multiplication to skip a lot of steps that are covered by the previous steps. first offset covers a 3*3 grid, second one a 9*9 grid, etc...
Last Edit: December 22, 2017, 08:51:42 am

It's crazy that, while the image is constantly sampled, you can't just take the highest point from the histogram and throw some math against it. Such a tedious technique to sample dominance.