# Area transformation

I have two rows of different types A and B. Every row is of the size 1$$\times$$N, where every element can be either 1 or -1.

If we consider a single row of type A={-1,1,1,1,-1,1,-1,...} of size 1$$\times$$N, I am processing this row by dot product with the following row 'mask' of size 1$$\times$$N.

mask(x) - $$Equation(1.1)$$:$$\frac{2}{N(N+1)}\sum_{n=1}^{N}N+1-x$$

Now, I change this mask by a factor 'b' and 'c' if the row type is A and B respectively. Thus, the shape of this mask (original in black and changed in blue for A, pink for B) would look like:

Now, if I have a row of 1$$\times$$N, where there are P elements are of type A and Q elements are of type B (is where I am stuck).

I tried the following:

I changed the mask of length P modifying N in equation 1.1 to N/2) and used the blue mask for first P elements and pink mask for next Q elements. Now, I am not sure how to add them up.

I think it would be on mapping the blue and pink area to the original triangle formed by black lines. But not sure how to relate them exactly.

Any hints or guide will be helpful.