Aspect Ratio help needed

mjohnson3091
01-29-2005, 01:25 PM
Hi All,

Can anybody help me with this problem I have.

I need to produce a pattern design for a machine which has an obscure aspect ratio.

For example, the width of the design at 120 pixels can be 30.48cm and the length is 777 pixels for 100cm.

Obviously the aspect of this is all wrong, but it is an historic thing with the machine that 777 lines = 100cm.

If I set a picture box at 120 * 777 and draw a circle, it will inevitably not be a circle when it is created on the machine.

Can somebody advise the best way how to handle this.

If I scale the length down to get the aspect ratio correct that way, how do I go about scaling it up again when a design is drawn to give the correct length?

Thanks in advance for any help.

webbone
01-29-2005, 02:21 PM
It sounds from your description like the machine has non-square pixels - i.e. the "pixels" are not 1:1 aspect ratio themselves.

How you will want to deal with this depends on how you interact with this machine - I'm thinking perhaps this is some sort of printing/cutting device but you haven't said so that's just a guess.

Are you actually sending pixels to the device or are you sending commands such as "goto point (x,y)" where x and y are in cm?

You can have a 'drawing canvas' that has the correct aspect ratio for the output of your device (100:30.48) and then convert when sending commands to it, but this might not be how your system works so that is just a guess.

If you need to send pixel data to your device you'll need to convert your drawing from your display version to the device version, taking into account the fact that your pixels are 1:1 on the display version and the pixels on the device version need to be M:N (I haven't done the math to figure them out - you might already have done this).

If you can post some more information on what you are doing and what you need to output we can probably help suggest a way to accomplish your desired goal.

mjohnson3091
01-29-2005, 03:06 PM
It sounds from your description like the machine has non-square pixels - i.e. the "pixels" are not 1:1 aspect ratio themselves.

How you will want to deal with this depends on how you interact with this machine - I'm thinking perhaps this is some sort of printing/cutting device but you haven't said so that's just a guess.

Are you actually sending pixels to the device or are you sending commands such as "goto point (x,y)" where x and y are in cm?

You can have a 'drawing canvas' that has the correct aspect ratio for the output of your device (100:30.48) and then convert when sending commands to it, but this might not be how your system works so that is just a guess.

If you need to send pixel data to your device you'll need to convert your drawing from your display version to the device version, taking into account the fact that your pixels are 1:1 on the display version and the pixels on the device version need to be M:N (I haven't done the math to figure them out - you might already have done this).

If you can post some more information on what you are doing and what you need to output we can probably help suggest a way to accomplish your desired goal.

Thanks for the reply webbone.

I didn't mention the machine type to try and keep things simple.

It's a machine for making patterned carpets.

The 777 lines comes from the way the machine was designed to work many years ago, using an acetate sheet on a drum to produce the pattern. The drum had a circumference of 1m and it took 777 steps of a stepper motor to rotate one full revolution.

When computers where introduced, somebody decided to keep the 777 lines = 1m.

I was thinking that because the width is fixed (due to the needles on the machine), then that would be used as a datum and the length scaled accordingly. So for example, it would be 100/30.48 = approx. 3.3, so 120 * 3.3 = 396, so giving me an image of 120 wide by 396 long with a true aspect ratio......at least I think.

So my thoughts are if I draw a circle on screen it will produce a circle in the carpet.

The thing being, how do I get it back to the correct size for the machine (120*777)???

Hope that doesn't confuse things too much....

webbone
01-29-2005, 03:49 PM
Ok - you have confirmed what I was originally thinking, and the specifics should help us get to the right method to use.

Your general idea on the drawing area is correct - your 'physical aspect ratio' is 3.28084 give or take a few decimal places. If you were to use a 120 pixel value the other dimension would work out to:

(120 / 30.48) * 100 = 393.7 ~ 394 pixels W

Since, however, you have a 777 pixel dimension that you need to deal with you could make the drawing area the other way, i.e. 777W and then determine the correct H:

(777/100) * 30.48 = 236.8296 ~ 237 pixels H

So based on that you'll need a drawing area of either 394W x 120H or 777W x 237H (or some multiple thereof) for 'square pixels' (which is what your computer screen uses).

I'm thinking out loud here so bear with me - from what you describe it sounds like your 120 dimension is a physical limitation, i.e. you have 120 parallel needles that each make a stitch .254mm "wide" and you get 777 stiches/meter. Given this fact you probably want to go for matching to this dimension and then synthesizing the correct value for your 777 axis (it makes getting clean looking images easier).

So you probably want to have a drawing canvas that is 394W x 120H. The down side to this is that you are not getting full use of the accuracy inherent in your physical dimensions (the 777 vs. 394). I can think of different ways to go about this but without knowing more about the machine I'm not sure what will be best.

Is the end product something that can have multiple colors or does it just make a monochrome (i.e. black/white or blue/green or red/purple, etc) rug? I'm guessing the latter - in which case this gets a little easier.

If you can provide a little more information I think we can get a reasonably good solution. Or this discussion already may have gotten you going in the direction you need.

Ultimately I'm thinking you need a specialized image processing program that you can just pass an image file into and then select a region and convert that to suitable output... perhaps this is where you are headed?

mjohnson3091
01-30-2005, 02:19 AM
Ok - you have confirmed what I was originally thinking, and the specifics should help us get to the right method to use.

Your general idea on the drawing area is correct - your 'physical aspect ratio' is 3.28084 give or take a few decimal places. If you were to use a 120 pixel value the other dimension would work out to:

(120 / 30.48) * 100 = 393.7 ~ 394 pixels W

Since, however, you have a 777 pixel dimension that you need to deal with you could make the drawing area the other way, i.e. 777W and then determine the correct H:

(777/100) * 30.48 = 236.8296 ~ 237 pixels H

So based on that you'll need a drawing area of either 394W x 120H or 777W x 237H (or some multiple thereof) for 'square pixels' (which is what your computer screen uses).

I'm thinking out loud here so bear with me - from what you describe it sounds like your 120 dimension is a physical limitation, i.e. you have 120 parallel needles that each make a stitch .254mm "wide" and you get 777 stiches/meter. Given this fact you probably want to go for matching to this dimension and then synthesizing the correct value for your 777 axis (it makes getting clean looking images easier).

So you probably want to have a drawing canvas that is 394W x 120H. The down side to this is that you are not getting full use of the accuracy inherent in your physical dimensions (the 777 vs. 394). I can think of different ways to go about this but without knowing more about the machine I'm not sure what will be best.

Is the end product something that can have multiple colors or does it just make a monochrome (i.e. black/white or blue/green or red/purple, etc) rug? I'm guessing the latter - in which case this gets a little easier.

If you can provide a little more information I think we can get a reasonably good solution. Or this discussion already may have gotten you going in the direction you need.

Ultimately I'm thinking you need a specialized image processing program that you can just pass an image file into and then select a region and convert that to suitable output... perhaps this is where you are headed?

Thanks again webbone, you are understanding what I'm trying to acheive.

The machine actually produces High and Low pile areas in the carpet, known as sculptured designs, you've probably seen them around.

The 777 is a really strange thing, because not all 777 lines will actually be seen in the carpet. The way the pattern is clocked through to the machine it is possible to go through 2-3 patternlines before it makes the stitch!

This is the reason why the aspect ratio needs to be correct when doing the design.

I had a little play with the ratios as we both discussed above and it seems to look OK, the only problem is that a drawing area of 120 * 394, is actually quite small, so I think I need to look at some sort of zooming function to make it more reasonable to draw on. If I double both the width and height, how can I make one pixel appear as 2*2 pixels for drawing, Is it as simple as setting the drawwidth to 2?

Last night I was thinking about using Stretchblt to get the image back to the correct size (120*777) before converting it a machine file format. Is that the correct way to go? My only thoughts on this are the fact that patterns will need to be imported and exported, so a 777 line image may need to be edited at the 120*394 size, if I use stretchblt will I be guaranteed to get the image back to exactly the same as when it was designed?

Thanks again for you help.

webbone
01-30-2005, 10:16 PM
I believe that using StretchBlt should do what you are asking - the caveat on that is that I have not played with it so I don't know the exact algorithm used (I used to design Real Time video processing hardware that does this sort of thing so I know what is involved) - the particular thing I'm wondering is if you have a black and white image, will StretchBlt introduce gray shades due to the filtering involved?

I'm sure you can create a quick test program to try this out.

I had also thought that the 120x394 drawing area is rather small - I'm not sure that setting DrawWidth to 2 would get the result you expect since that will set your line width to 2 but won't have an effect on your positioning resolution (you could handle this in code but it might get tricky). Ultimately what you are wanting is to scale your drawing area up and then draw with a square brush that is the sized to match your scaled up area.

As for your concern about converting back and forth using StretchBlt I would suggest that you only convert one way (i.e. from your drawing canvas TO the target image for the rug maker) and if you store anything that you store it in the drawing canvas format.

Let me know if I'm just confusing you further or if this is helpful - I might try whipping up a sample app to do this if I get some free time since it has been awhile since my last graphics related project and this sounds interesting and different than just your average paint program! :)

mjohnson3091
01-31-2005, 01:01 AM
I believe that using StretchBlt should do what you are asking - the caveat on that is that I have not played with it so I don't know the exact algorithm used (I used to design Real Time video processing hardware that does this sort of thing so I know what is involved) - the particular thing I'm wondering is if you have a black and white image, will StretchBlt introduce gray shades due to the filtering involved?

I'm sure you can create a quick test program to try this out.

I had also thought that the 120x394 drawing area is rather small - I'm not sure that setting DrawWidth to 2 would get the result you expect since that will set your line width to 2 but won't have an effect on your positioning resolution (you could handle this in code but it might get tricky). Ultimately what you are wanting is to scale your drawing area up and then draw with a square brush that is the sized to match your scaled up area.

As for your concern about converting back and forth using StretchBlt I would suggest that you only convert one way (i.e. from your drawing canvas TO the target image for the rug maker) and if you store anything that you store it in the drawing canvas format.

Let me know if I'm just confusing you further or if this is helpful - I might try whipping up a sample app to do this if I get some free time since it has been awhile since my last graphics related project and this sounds interesting and different than just your average paint program! :)

Thanks for the reply again and apologies for my delayed response.

I had a little play with the stretchblt and it seems to stretch without giving any grey areas on a black and white image. I'll probably have to try this some more, as if in some circumstances that it occurs then the conversion to the machine format will fail because it won't recognise the colour as it is only a two state machine (High and Low).

I also tried the scaling the image up by 2 and setting the drawwidth to two and it does exactly what you said, I get a 2*2 brush that moves a single pixel.....hmmmm...not sure what to do about that one.

I agree about the storing the images in the "drawing" format, but in some circumstances it may be necessary to import a pattern from another system. Again I'll have a play with this, by importing it, scaling it down and exporting it again. It will be interesting to see the results.

I see you background is totally suited to graphical things. My background is in Electrical/Electronic engineering and machine automation. I used to design the machines that this system is trying to output to, but my graphics skills are lets say, somewhat limited!

Thanks again for your assistance.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum