hd8fdkd
![]() |
Is there way to get the size and center coordinates of selection area?
I want to scale selection area without moving its center coordinates. In addition, I want to get selection area's width and height pixels. |
|||||
Posted: September 15, 2011 1:37 am | ||||||
Sphinx.
![]() |
The selection must be same size as the image loaded. If you use Transform > Scale component, just set the XY Anchor to "Image Bounds", then 0.5,0.5 will be the center, and you can set any scale you want..
|
|||||
Posted: September 15, 2011 3:05 am | ||||||
hd8fdkd
![]() |
Sphinx, thank you for your reply. In the Selection component, selected area is white square and unselected is black. I wanted to scale white square (selected area) while keeping the original center coordinates. I tried your method, but scale component applied to center of whole image. (Scale component's parameter set the XY Anchor to "Image Bounds". And origin X and origin Y set to 0.5.) ![]() |
|||||
Posted: September 15, 2011 4:46 am | ||||||
Sphinx.
![]() |
Oh! That's a whole different story!
There is no simple way to do that, because you only have information about the whole selection map as such available. Selection data can also be gradual (i.e. graytones). What you need here is some sort of autotrim method that gives you the bounding rect of non zero selection samples. This is somewhat complicated to figure out when you work in a procedural rendering context.. Maybe it would be better to go at the problem from another perspective: what is your overall idea / goal here? |
|||||
Posted: September 15, 2011 5:01 am | ||||||
hd8fdkd
![]() |
I think that selection size and center information is useful for creation of new filters. It is also helpful for updating existing filters. For example, my filter "Stamp Maker" needs selection. And this filter uses Frame components to make frame of stamp. If I could get the selection size, I would reduce the margin between selection and frame. I tried two things. First, I tried to get these value by using "for loop". (from 0 to 1, and step is 1 pixel) ex.
But this code was too heavy and I couldn't get the result which I wanted. Next, I used Blur component as scaling tool. But this was too difficult for me to got the actual value.(ex.twice the width of selection) |
|||||
Posted: September 15, 2011 6:59 am | ||||||
Sphinx.
![]() |
Yes, a script is currently the only way to search down the bounding rect, and it can be done in a fairly optimal way IF we just didn't have that darn initialization overhead issue...
But even with that problem, you could optimize the search using this method. Basically you perform the search inside the initialization section. The search must be performed in two steps: 1. search from top,left and forth to first encounter of a non zero sample (or the sample value of the top, left coordinate). At first encounter break the loop. 2. like above, but search from bottom, right and back instead. you can output the values through r,g,b,a (top, left, bottom, right). Btw..alternatively to your blur attempt, try using maximum or median instead of a blur... |
|||||
Posted: September 15, 2011 8:04 am | ||||||
hd8fdkd
![]() |
Thanks to your advice, I could scale selection without moving center. But code is very heavy. Additionally, the width and height of selection area is slightly different from original.(few pixels)
I tried using Maximum component. Radius control minimum is 0.01. When the value set to 0.01, each edge increase 4 pixels.(when whole image size is 512 x 512) I think detailed control is difficult. |
|||||
Posted: September 15, 2011 11:26 pm | ||||||
hd8fdkd
![]() |
Sphinx, thanks anyway.
I will try these approachs again until another approach will be found. |
|||||
Posted: September 17, 2011 8:53 pm | ||||||
ThreeDee
![]() |
A thought on this matter: Not the prettiest of solutions, but you could blur the selection image with directional blur horizontally for the vertical values and vertically for horizontal values (with motion blur component set to radius 100, directional 100, angle 0 or 90, not gaussian). Then perform the seach for non-zero values along x and y-axis from the edges on in. This way you'd only need to seach one row of pixels in each direction. I assume this would be faster than a purely script-based solution.
|
|||||
Posted: September 18, 2011 3:07 pm | ||||||
hd8fdkd
![]() |
ThreeDee, thank you for your reply.
You're amazing ! Now I can get the value of selection area width, height and center coordinates. I used "Motion" blur instead of "Directional" one. Because there is no "Directional Blur" Component. Except it, I used your method. If selection area has very long edge, it may need more steps below. "Directional Blur" >>> "Threshold" >>> "Directional Blur"... I'm going to continue to improve. Thanks. |
|||||
Posted: September 19, 2011 7:52 am |
Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!
33,711 Registered Users
+18 new in 30 days!
153,533 Posts
+31 new in 30 days!
15,348 Topics
+73 new in year!
28 unregistered users.