Welcome to WSL!

New to the forum? Please read this and this.

[DEV] Center of mass

Where the future is being made, today.

Welcome to the WSL development corner!

In this forum, please post your development projects. You get kudos and feedback here.
Topics ideally have preset prefixes, and this is what they (might) mean:

  • [DEV] - very much work in progress, don't build a business on this, could go anywhere
  • [BETA] - should kinda do what it's supposed to do, please test, give feedback
  • [RC] - this may end up in Reactor soon, polishing up, now's the time for last minute thoughts
  • [ABD] - died a premature death, sadness, will not see the light of day ever (unless someone picks up the scraps)

Once a development project has been released (hurray), topics can be marked as - you guessed it - [RELEASED] :cheer:

Development topics only, please. For generic questions, how-to's, questions and inquiries about existing tools etc, please go to the appropriate other forums.
User avatar
tida
Fusionista
Posts: 257
Joined: Mon Jan 27, 2020 4:37 am
Answers: 1
Real name: none
Been thanked: 41 times

Re: [DEV] Center of mass

#16

Post by tida »

@danell thanks for the feedback. Now additional options:
A) show/hide either Mass Object and Center Object
B) blend slider for the two images
C) color sliders to weighting either R, G, and B (standard is luminance)
D) average slider to smoothen center of mass movements

Would be great to get some more feedback.
td_CenterOfMass.fuse
You do not have the required permissions to view the files attached to this post.

User avatar
tida
Fusionista
Posts: 257
Joined: Mon Jan 27, 2020 4:37 am
Answers: 1
Real name: none
Been thanked: 41 times

Re: [DEV] Center of mass

#17

Post by tida »

This version works with an Output. You don't need to connect the Center Object to the Fuse. You are also able to use the ConnectTo-Method for X/Y-Points as well as for X or Y Numbers.
td_CenterOfMass.fuse
You do not have the required permissions to view the files attached to this post.

User avatar
danell
Fusionista
Posts: 255
Joined: Mon Dec 12, 2016 6:32 am
Been thanked: 14 times

Re: [DEV] Center of mass

#18

Post by danell »

Thank you so much for your work with all these fuses! This and the RotoRefine is so fast and so great! <3

User avatar
tida
Fusionista
Posts: 257
Joined: Mon Jan 27, 2020 4:37 am
Answers: 1
Real name: none
Been thanked: 41 times

Re: [DEV] Center of mass

#19

Post by tida »

Thanks @danell, the combination of a DCTL and the Outputs was a little bit tricky. To let the Output working you need to run the PreCalcProcess function. The processing of the Output image needs to be handled by a global image variable which is filled up only in the Process function.

But in general, it could be simplified to a Modifier whereas the image is handled like in the Probe Modifier...

User avatar
tida
Fusionista
Posts: 257
Joined: Mon Jan 27, 2020 4:37 am
Answers: 1
Real name: none
Been thanked: 41 times

Re: [DEV] Center of mass

#20

Post by tida »

Center of mass with additional size control. Did also include a switch that can choose between white (brightness) or black (darkness) for the center of mass calculation. Alpha channel is important when it comes to include black (darkness)
td_CenterOfMass.fuse
You do not have the required permissions to view the files attached to this post.

User avatar
tida
Fusionista
Posts: 257
Joined: Mon Jan 27, 2020 4:37 am
Answers: 1
Real name: none
Been thanked: 41 times

Re: [DEV] Center of mass

#21

Post by tida »

Next Version:
A) Added Stabilize checkbox. Now you can also stabilize either X,Y or XY position of source (mass) image when appending a Transition and Connect-To it's Center.
B) Improved averaging by implementing internal frame re-timing. The average position is now exactly the determined mean value. Old version had a lag in time as it did not take into account future frames.
td_CenterOfMass.fuse
You do not have the required permissions to view the files attached to this post.

User avatar
tida
Fusionista
Posts: 257
Joined: Mon Jan 27, 2020 4:37 am
Answers: 1
Real name: none
Been thanked: 41 times

Re: [DEV] Center of mass

#22

Post by tida »


User avatar
danell
Fusionista
Posts: 255
Joined: Mon Dec 12, 2016 6:32 am
Been thanked: 14 times

Re: [DEV] Center of mass

#23

Post by danell »

Great work once again! I was actually using the fuse yesterday to stabilize some stuff. Now it's even easier! haha

User avatar
tida
Fusionista
Posts: 257
Joined: Mon Jan 27, 2020 4:37 am
Answers: 1
Real name: none
Been thanked: 41 times

Re: [DEV] Center of mass

#24

Post by tida »

Sorry, for the bunch of new versions:
A) Added MultiButtonControl to choose between Stabilizing method much faster.
B) Changed to Canvas Sampling for Center Object Image Output
C) Direct access to stabilizing effect. (If the second image Channel is not connected it will use a Duplicate for the Center Object)

Hopefully, it's more intuitive to use.
td_CenterOfMass.fuse
You do not have the required permissions to view the files attached to this post.

User avatar
tida
Fusionista
Posts: 257
Joined: Mon Jan 27, 2020 4:37 am
Answers: 1
Real name: none
Been thanked: 41 times

Re: [DEV] Center of mass

#25

Post by tida »

@danell did modify your blob fuse. It works out to sent just one point to each center of multiple masses. It's possible to integrate the analysis directly in the second pass and have a short third pass to place the center pixels.

The following image is the result of a bokeh convolve with an "X" as bokeh object, subsequently blended with the original image form @SirEdric ...
0AED5213-780A-43CF-8092-B657CFC3E00E.jpeg
This are some results which has been analyzed:
37A5D2BB-378B-4D48-A95F-B43EE99F78A5.jpeg
Added in 50 minutes 28 seconds:
Thats what I changed:
  1.         -- Second pass
  2.         local numLabels = 0
  3.         massdat = {}
  4.         for x=0, width-1 do
  5.             for y=0, height-1 do
  6.                 if labels[x][y] ~= nil and labels[x][y] ~= 0 then
  7.                     labels[x][y] = uf:root(labels[x][y])
  8.                     lbl = labels[x][y]
  9.                     if colors[lbl] == nil then
  10.                         numLabels = numLabels + 1.0
  11.                         colors[lbl] = {math.random(), math.random(), math.random()}
  12.                         massdat[numLabels] = {width, 0, height, 0, 0, 0, 0}            
  13.                     end
  14.                     p.R = colors[lbl][1]
  15.                     p.G = colors[lbl][2]
  16.                     p.B = colors[lbl][3]
  17.                     local mdID = colors[lbl][4]
  18.                     p.A = 1.0
  19.                     if boolMasses > 0 then out:SetPixel(x, y, p) end
  20.  
  21.                     xmin = massdat[mdID][1]
  22.                     if x < xmin then massdat[mdID][1] = x end
  23.                    
  24.                     xmax = massdat[mdID][2]
  25.                     if x > xmax then massdat[mdID][2] = x end
  26.                    
  27.                     ymin = massdat[mdID][3]
  28.                     if y < ymin then massdat[mdID][3] = y end
  29.                    
  30.                     ymax = massdat[mdID][4]
  31.                     if y > ymax then massdat[mdID][4] = y end
  32.                    
  33.                     area = massdat[mdID][5]
  34.                     area = area + 1.0
  35.                     massdat[mdID][5] = area
  36.  
  37.                     sumX = massdat[mdID][6] + x
  38.                     sumY = massdat[mdID][7] + y
  39.                     massdat[mdID][6] = sumX
  40.                     massdat[mdID][7] = sumY
  41.  
  42.                 end
  43.             end
  44.         end
  45.  
  46.         p.R = 1
  47.         p.G = 1
  48.         p.B = 1    
  49.         print("numlabels: " ..numLabels)
  50.         for mdID=1, numLabels do
  51.  
  52.             xmin = massdat[mdID][1]
  53.             xmax = massdat[mdID][2]
  54.             ymin = massdat[mdID][3]
  55.             ymax = massdat[mdID][4]
  56.             area = massdat[mdID][5]
  57.             xc = massdat[mdID][6]/area --center of mass
  58.             yc = massdat[mdID][7]/area --center of mass
  59.             if boolEdges > 0 then
  60.                 out:SetPixel(xmin, ymin, p)
  61.                 out:SetPixel(xmax, ymax, p)
  62.             end
  63.             if boolCenter > 0 then out:SetPixel(xc, yc, p) end
  64.             if boolPrintData > 0 then print(" xmin: " .. xmin .. " xmax: ".. xmax .. " ymin: " .. ymin .. " ymax: " .. ymax .. " area:" ..area .. " xc: " .. xc .. " yc: " .. yc ) end
  65.         end
  66.        
  67.  
You do not have the required permissions to view the files attached to this post.