# geometric progression, I think

#### zemlik

##### New member
hello, If this is in the wrong category perhaps somebody can move it ?
I try to manipulate an image.
"zoom" in on it by cutting out a width from it.
each new image is proportionally smaller ( or bigger ) by the same amount
small=sqrt((big^2)*(1-p)^f)
where f is the next progression (frame) and p is the proportion
and p = 1- ((small^2)/(big^2))^1/f
That's the widths found.
what I want to do is move the x,y position on the image in the same proportion as the widths.
say x starts at 100 and ends at 800 I can apply the same equation to the x position and it sort of looks alright but I'm not sure it is tied properly to the widths.
I am struggling a bit working it out and wouldn't mind some help.
the first and last value of x is fixed and the frames (f) are fixed but somehow the change in x wants to be related to the formula to determine the width.
whatever the first change of x ( measured in pixels) x(1) to x(2) it will be a proportion of the first width ( measured in pixels) width(1) to width(2)
that proportion change of x wants to be of the same proportion as the next to last and last width.

Last edited:

#### Dr.Peterson

##### Elite Member
This is very hard to follow.

How about if you start out by describing what you want to do, without any math at all. Be sure to define terms. A labeled picture might help.

Among the things here that make little sense to me are f (which has to be a number, not a "frame"), "small" and "big" (which also must be numbers, but you haven't said anything about what they refer to). I also can't tell what "cutting out a width" means.

#### zemlik

##### New member
this is example.
from a series of images all the same size I cut out a part of the images progressively and enlarge those cutout bits to the same size so that is like a zoom. Those are the widths.
In this example I move the x.y position ( the top left hand corner where the cut out image starts) with the progressive formula as described.
f is frames.
p is proportion.
big is the start size.
small is the end size.
I appears to work but the movement x,y is to do with the x,y start and end position. It should be that be also tied to what ever size width of that particular image.
I think there should be a way to relate the x,y change exactly to the width change.

#### Dr.Peterson

##### Elite Member
This still needs a lot of clarification. Let's see if I can do that.

You are given a set of images, and you want to enlarge each one, successively, a little more than the previous one; in order to do that, you need to choose a rectangle in each original that will be enlarged to full size. This rectangle is identified apparently by the coordinates (x, y) of its upper left corner, and it extends always to the lower right corner. I think all distances are measured in pixels.

It is meaningless to say "f is frames"; "frames" is not a number. I have to guess that you mean "f is the index of a particular frame", so that the first frame corresponds to f=1, the second to f=2, and so on. Is that right?

It is similarly unclear to say "p is proportion"; what proportion? You could mean the aspect ratio of the rectangle, for example. Looking back at your equations, it looks like you mean, "p is the fraction of the total area that is removed at each step", or something like that. This really needs clarification, as it appears to be central to your request.

As for "big" and "small", you call these the start and end size ... of what? Do you mean the width of the rectangle that you are enlarging, so that "big" is the width of the entire window on screen, and "small" is the width of the rectangle that you are enlarging to that size? Or are they heights? Or something else entirely?

So I am not clear yet on what the variables mean. You can confirm or correct each thing I've said here, and perhaps also give a simplified numerical example. What are typical values of the variables, maybe just for the first and second frames of a sequence?

And a sketch, labeled with the variables, would be very helpful. Maybe show a rectangle within a rectangle, with various distances labeled, and show what p would be.

#### zemlik

##### New member
OK
I try
say I have an image I want to cut out a bit of that image by a proportion of it's area and enlarge that cut out piece to a size ( can be anything)
then do the same thing to that bit that I cut out. ( looks like a zoom in cinema)
first image is called "big" and it is a size in width measured in pixels .
second is big-(big*p) ( p is a fraction)
third is (big-(big*p))-((big-(big*p))*p)
fourth is (big-(big*p))-((big-(big*p))*p)-)(big-(big*p))-((big-(big*p))*p)*p)
and so on
that is sqrt((big^2*(1-p)^number)
looks like this
but I want to change the xy position in the same way so that the proportion that the xy co-ordinate changes in relation to the first image is the same as the change on all the other images but still start and end up in the defined place.
for example this is not right.
Maybe this is understandable or do I need to print something out, draw on it, scan it, upload it ?

#### Dr.Peterson

##### Elite Member
You're programming, right? Why can't you understand that variables have to be defined? Programmers have to know how to clearly specify what a project will do, and what each quantity means. Also, you are not interacting with me: I specifically asked you to confirm or correct each statement I made, and here you are starting over, and still only barely defining anything.

If "big" is an image, you can't multiply it by something! It must represent some number. Please say that directly. "Big" is not what the "first image is called"; it is the width of that image, right??

Then, what is it that is represented by each subsequent expression? Are those the widths of subsequent portions of the original image? It appears that you are multiplying the width (and probably the height as well) by 1-p at each step. (Why not just by p? That would make this easier to talk about. What are you thinking of p as meaning?)

But then you move on to "sqrt((big^2*(1-p)^number)" . Here it looks like you are trying to multiply the area, rather than the width, by 1-p each time. Why the change?

What I want to you say is what your actual goal is. At each step, do you want to reduce the width, or the area, or something else, by a given fraction?

Now, in your two images, you show the center of the rectangle moving in ways that you have not explained at all. In the first one, the center is fixed; are you using (x,y) to mean the center of the rectangle? You've never said! When you say the second image is wrong, do you mean that the center should stay fixed? You've never stated your goal.

We'd be taking a lot less time if you'd only tell me what x means, and where you want each rectangle to be located.

#### zemlik

##### New member
perhaps forget what it tries to do
let's then say there are 2 sequences of numbers
1 sequence starts at number 1000 and changes according to progression sqrt((1000^2*(1-p)^steps)
the start number is important
then you want another sequence of numbers. where the actual numbers are unimportant but the difference between them is what concerns you.
you want to change in same number of steps for example 0 -> 345 in the same way as sequence 1.
maybe that's all I need to do but I was thinking it should be tied to how big the start of sequence 1 is.
I've tried to explain this 4 times now. shown a moving illustration and 2 graphics. Which I would have thought was enough to show what my concern is.

Last edited:

#### Dr.Peterson

##### Elite Member
This does no better at defining the problem!

What does "in the same way" mean? What am I supposed to do with the "difference between [successive numbers]"?

We could figure this out from your actual goal much more easily than trying to untangle your vague language.

Can you just tell me what your x refers to? Was it the x-coordinate of the center of the rectangle, or something else?

Let's suppose you're trying to make smaller and smaller rectangles, keeping the same center. Suppose you have a formula for the width of the rectangle, and what you need is to find the upper left corner so that the center remains at the center of the big rectangle. Then we can define:
• big = width in pixels of original rectangle
• small = width in pixels of smaller rectangle
• x = pixel offset from left edge of big rectangle to left edge of small rectangle
We can then observe that 2x + small = big, since we want equal spaces on both sides; so x = (big - small)/2. That's all you need, if you already have a formula for small as a function of big and n, the number of steps taken (which I think you do).

That's how easy this can be if you state what you want.

#### zemlik

##### New member
yes I know where the top left corner is in relation to the centre at different size rectangles.
Do you not see that my problem is moving the centre from a point A to another point B ( on the x axis but also on the y axis )
in the same proportion of the distance that the area of the rectangle changes ?

#### Dr.Peterson

##### Elite Member
Do you not see that my problem is moving the centre from a point A to another point B ( on the x axis but also on the y axis )
in the same proportion of the distance that the area of the rectangle changes ?
No, I don't. You have never mentioned area yet! And I'm not sure what it means for a distance to be proportional to an area.

Please state the goal exactly. If necessary, give a specific numerical example.

#### zemlik

##### New member
In post number one I said
"what I want to do is move the x,y position on the image in the same proportion as the widths. "
I should have been clearer.
x,y position can mean the centre point of the rectangles.
illustrated there I change the size of the rectangle W1 -> W2 using equation described previously so that area changes each time at a constant proportion of previous rectangle.
the widths of the rectangles might go like this
1000
851
724
617
525
447
380
324
275
234
200
you'll see that there is a bigger difference between the big numbers at the start to the smaller numbers at the end.
at the same time I want to change the centre of the rectangles from A -> B
The change in the x and y co-ordinates of the centres of the rectangles should be in the same proportions as the change in the widths.
if the x position starts at 1000 and ends at 200 as well then it would be the same.
but x might start at 87 and change to 1463
How can I change x from 87 to 1463 in the same way the width goes from 1000 to 200 ?
so x would be something like 87, 487, 780, 930, 1050, 1160, 1260, 1340, 1400, 1443, 1463

Last edited:

#### Dr.Peterson

##### Elite Member
This is much better; but there's still some clarification needed, which I'll try to get from the example.

My first interpretation is that you want a linear relationship between x and w, so that, for example, (x-87)/(w-1000), the ratio of the change in x from the start to the change in w from the start, is constant. But that's not what you've done here: (1463-87)/(200-1000) = -1.72, while (487-87)/(851-1000) = -2.68.

But in case your x's were not meant to be accurate, here is what my spreadsheet gives for this example, so you can see if it does what you want:

 n: 10​ p: 0.27522​ w x start: 1000​ 87​ final: 200​ 1463​ n w x 0​ 1000​ 87​ 1​ 851​ 343​ 2​ 725​ 560​ 3​ 617​ 746​ 4​ 525​ 903​ 5​ 447​ 1038​ 6​ 381​ 1152​ 7​ 324​ 1249​ 8​ 276​ 1332​ 9​ 235​ 1403​ 10​ 200​ 1463​

Does that work?

#### zemlik

##### New member
That certainly looks like what is wanted. Can you show me the calculation ?
I have certainly been struggling to see it.

#### Dr.Peterson

##### Elite Member
It's just the two-point form of the line through (w_i, x_i) and (w_f, x_f), that is, the initial pair and the final pair. My formula is

x_i + (w - w_i)*(x_f - x_i)/(w_f - w_i)​

Here, (x_f - x_i)/(w_f - w_i) is the slope, which I am multiplying by the change in w, (w - w_i), and adding to the initial x, x_i.

#### zemlik

##### New member
I don't know why I didn't see it. The total distance divided by the total width change is a fraction.
Mutiplying a new width change by that fraction is the change in distance.
I was trying to calculate the distances directly but as I know the new widths then that is enough.