Getting Brightest and Darkest Pixels in COP

   3702   11   2
User Avatar
Member
471 posts
Joined: Nov. 2013
Offline
Hi all.
I'm wondering if there is a way to get brightest and darkest RGB values in COP context.
I searched and found this thread without any clear answer: http://forums.odforce.net/topic/3417-brightest-point-in-image/ [forums.odforce.net]
Any ideas?
Thanks.
Edited by Nima - June 6, 2017 03:43:50
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
Hi Nima,

in SOPs attribute promote has methods for getting the highest and lowest value of an attribute. I promoted the results to detail and imported them to COPs inside a VOP COP2 filter.
Edited by Konstantin Magnus - June 7, 2017 17:07:39

Attachments:
brightest_darkest.hipnc (130.5 KB)
photo_colors.jpg (5.7 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
471 posts
Joined: Nov. 2013
Offline
Hello Konstantin Magnus.
Really thanks for your help.
This method works fine when your image has low resolution.
My image has resolution of 3200 by 2400 and definitely it's not a good way to create a grid in that resolution in SOP!
I am just thinking about doing this in chop.
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
Why dont you scale it down in COPs then? Or change the grid´s expression to something like
res("op:/img/comp1/image", D_XRES) / 10
Edited by Konstantin Magnus - June 8, 2017 05:21:34
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
471 posts
Joined: Nov. 2013
Offline
I'm afraid of losing one of max or min pixels during scale down process.
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
Well, I dont know what you are working on of course, but on a large photo I dont think it would be noticeable.

On the contrary scaling would reduce image errors and noise.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
471 posts
Joined: Nov. 2013
Offline
Dear Konstantin Magnus, I wanna divide color of each pixel to color of brightest pixel in image.
This is away more efficient than do it in SOP so I'm looking for a solution to do this in cop itself.
Edited by Nima - June 8, 2017 07:15:59
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
I guess you have to loop through all pixels using either VOPs or python then.

http://www.sidefx.com/docs/houdini/hom/pythoncop [www.sidefx.com]
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
471 posts
Joined: Nov. 2013
Offline
Really Thanks.
I will take a look at that.
Edited by Nima - June 8, 2017 07:40:57
User Avatar
Staff
6205 posts
Joined: July 2005
Offline
With Houdini 16 you can import an image into SOPs as a volume slice in addition to as meshes.

Put a COP Network down in SOPs, point it to your COP network, then set it to Volume Slice.

Then you can use Volume Reduce in Max or Min mode to put the resulting max/min into detail attributes.

You'll notice this generates different results than the attribfrommap solution - I suspect it is mis-applying linearlization somewhere. The volume solution seems correct.

You can also do this entirely in COPs.

Dilate/erode will act as a maximum/minimum in a square region depending on sign of the operation. Ideally you could just set this to 3200 for your 3200x3200 image, but because COPs tries to compute the overscan this gets too expensive. So instead do two passes. First dilate/erode by 128. Then scale by 1/64 which will be safe - you won't miss any max/mins because each max/min already got spread everywhere in 128 tiles. Now do another dilate/erode and get a solid patch of colour for use elsewhere in COPs.

Attachments:
brightest_darkest_volumes.hipnc (141.3 KB)

User Avatar
Member
471 posts
Joined: Nov. 2013
Offline
Your HIP file is exactly what I want.
Thank you so much Jeff.
Edited by Nima - June 8, 2017 16:34:34
User Avatar
Member
471 posts
Joined: Nov. 2013
Offline
One last thing how can I tweak C.r, C.g and C.b attributes?
I try to tweak them in a volume wangle but VEX gives me error.
I also change them to Cd.r, Cd.g and Cd.b with the help of name node but just get completely white image!
  • Quick Links