Simple Question: how do I subtract a single column value from all of the rest?

This seems like it should be relatively straightforward, but for the life of me... it isn't.

 

I have a single column of values where I need to specify one row position that thenn needs to be subtracted from all of the rest of the values in that column or a duplicate - I'm just trying to subtract of a calculated background value.

 

Thanks in advance.

Hi,

I would say its not immediately obvious to do, but it can be done if you are familiar with flow variables.

You need to take your dataset, attach a "row filter", and filter the data such that the only row left, is the one with the background value.

Now attach the "tablerow to variable" node, followed by attaching an "Inject Variables (data)" node with the red blobs. To the second in-port of the "Inject Variables" node, attach the whole dataset (prior to the row filter node). Now attach a Maths node, and enter a column name next to append column, now go to flow variables tab and select the column name with the background value in it, click OK. The result of this is a new column which has the background value in every row. Now simply attach a second Math node and subtract the original column with this new column containing the background value.

Hope that helps,

Simon.

1 Like

Hi, 

Should this alos work with images, or only for numbers?  I have a set of images, and a single(Averaged) background image and I can't figure out how to get them in the same table, image and background image in same row, to subtract one from the other.

Many Thanks

Hi, 

No worries I worked out how to do it.  I added a column of constant value (pixel number) then I could join the two tables even with different number of rows.  It's easy when you know how!!

Cheers