Home All Groups Group Topic Archive Search About

Non-proportional (non Rectangular) resizing

Author
26 Jan 2007 10:47 AM
GraGra33

Hi all...

I have developed an application for managing a very large resource of
artist's paintings and posts them to a web site. The application works well.
I'm trying to reduce the complexity of having to work with photoshop and
integrate one feature into the application > Distortion Transformations.

Background Information:

When paintings are photographed, it's impossible to get a completely perfect
image that requires straightening prior to cropping for a number of rasons -
the photographer is not standing square on to the painting, the painting is
leaning, the camera is not at the correct height,  the camera causes barrel
distortion, etc...

Therefore each image must be loaded into photoshop, all 4 corners selected
using the polygonal lasso tool then manually applying a Distort
Transformation (Edit > Transform > Distort) on the selected region.

The Problem:

The GDI library comes standard with several rectangular transformations -
stretch, Skew, etc.. But these apply only to a perfect rectangular region
where all points are perpendicular to each other.

I have no problems in selecting the non-rectangular region - this is easy.
I'm stumped at trying to work out how to take this region and applying the
Photoshop like Distort Transformation.

Anyone have any pointers?

Thanks in advance...

Graeme
Author
26 Jan 2007 11:50 AM
Kevin Spencer
Transformations are all done using Matrix math. This is not going to be an
easy task, because you will have to understand Matrix math to do it. Here
are some articles and sample code to get you started:

http://www.bobpowell.net/transformations.htm
http://www.codeproject.com/csharp/matrix_transformation.asp
http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

Show quoteHide quote
"GraGra33" <gragr***@hotmail.com> wrote in message
news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
> Hi all...
>
> I have developed an application for managing a very large resource of
> artist's paintings and posts them to a web site. The application works
> well.
> I'm trying to reduce the complexity of having to work with photoshop and
> integrate one feature into the application > Distortion Transformations.
>
> Background Information:
>
> When paintings are photographed, it's impossible to get a completely
> perfect
> image that requires straightening prior to cropping for a number of
> rasons -
> the photographer is not standing square on to the painting, the painting
> is
> leaning, the camera is not at the correct height,  the camera causes
> barrel
> distortion, etc...
>
> Therefore each image must be loaded into photoshop, all 4 corners selected
> using the polygonal lasso tool then manually applying a Distort
> Transformation (Edit > Transform > Distort) on the selected region.
>
> The Problem:
>
> The GDI library comes standard with several rectangular transformations -
> stretch, Skew, etc.. But these apply only to a perfect rectangular region
> where all points are perpendicular to each other.
>
> I have no problems in selecting the non-rectangular region - this is easy.
> I'm stumped at trying to work out how to take this region and applying the
> Photoshop like Distort Transformation.
>
> Anyone have any pointers?
>
> Thanks in advance...
>
> Graeme
>
>
Are all your drivers up to date? click for free checkup

Author
26 Jan 2007 11:50 AM
Kevin Spencer
Transformations are all done using Matrix math. This is not going to be an
easy task, because you will have to understand Matrix math to do it. Here
are some articles and sample code to get you started:

http://www.bobpowell.net/transformations.htm
http://www.codeproject.com/csharp/matrix_transformation.asp
http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

Show quoteHide quote
"GraGra33" <gragr***@hotmail.com> wrote in message
news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
> Hi all...
>
> I have developed an application for managing a very large resource of
> artist's paintings and posts them to a web site. The application works
> well.
> I'm trying to reduce the complexity of having to work with photoshop and
> integrate one feature into the application > Distortion Transformations.
>
> Background Information:
>
> When paintings are photographed, it's impossible to get a completely
> perfect
> image that requires straightening prior to cropping for a number of
> rasons -
> the photographer is not standing square on to the painting, the painting
> is
> leaning, the camera is not at the correct height,  the camera causes
> barrel
> distortion, etc...
>
> Therefore each image must be loaded into photoshop, all 4 corners selected
> using the polygonal lasso tool then manually applying a Distort
> Transformation (Edit > Transform > Distort) on the selected region.
>
> The Problem:
>
> The GDI library comes standard with several rectangular transformations -
> stretch, Skew, etc.. But these apply only to a perfect rectangular region
> where all points are perpendicular to each other.
>
> I have no problems in selecting the non-rectangular region - this is easy.
> I'm stumped at trying to work out how to take this region and applying the
> Photoshop like Distort Transformation.
>
> Anyone have any pointers?
>
> Thanks in advance...
>
> Graeme
>
>
Author
26 Jan 2007 10:44 PM
GraGra33
Hi...

Thanks for your suggestions - I've had a look at all the links mentioned.
Bob's and the CodeProject artile I've already looked at both and they deal
with rectangular regions (simple transformation) and not 4-point polygons
(complex transformation).

I've also looked at Gimp and Paint.Net - both only deal with regions (simple
transformation)  and don't have Photoshop's distort transformation (complex
transformation).

I'm trying to do 4-point polygons (complex transformation) and not
rectangular regions (simple transformation). The GDI+ matrix transformations
only handle rectangular regions (simple transformation) as far as I can
ascertain.

To clarify what I'm trying to do, I'll give you another example - can send
you a sample image if you think that you know how it's done.

Example: The bottom-left and top-right corners are not squared to the
Top-left & bottom-right corners. To square the image, the top-left and
bottom-right must stay anchored whilst the bottom-left must be distorted
towards the top and the top-right corner must be distorted to the right.

Be aware that no two photos are the same and each photo will require
different distort transformation adjustments.

Do you still think that your suggestion will work or do you have another
idea?

Thanks for your help in advance,

Graeme

Show quoteHide quote
"Kevin Spencer" <unclechut***@nothinks.com> wrote in message
news:e2CH2AUQHHA.1200@TK2MSFTNGP02.phx.gbl...
> Transformations are all done using Matrix math. This is not going to be an
> easy task, because you will have to understand Matrix math to do it. Here
> are some articles and sample code to get you started:
>
> http://www.bobpowell.net/transformations.htm
> http://www.codeproject.com/csharp/matrix_transformation.asp
> http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
> http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Software Composer
> http://unclechutney.blogspot.com
>
> The shortest distance between 2 points is a curve.
>
> "GraGra33" <gragr***@hotmail.com> wrote in message
> news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
>> Hi all...
>>
>> I have developed an application for managing a very large resource of
>> artist's paintings and posts them to a web site. The application works
>> well.
>> I'm trying to reduce the complexity of having to work with photoshop and
>> integrate one feature into the application > Distortion Transformations.
>>
>> Background Information:
>>
>> When paintings are photographed, it's impossible to get a completely
>> perfect
>> image that requires straightening prior to cropping for a number of
>> rasons -
>> the photographer is not standing square on to the painting, the painting
>> is
>> leaning, the camera is not at the correct height,  the camera causes
>> barrel
>> distortion, etc...
>>
>> Therefore each image must be loaded into photoshop, all 4 corners
>> selected
>> using the polygonal lasso tool then manually applying a Distort
>> Transformation (Edit > Transform > Distort) on the selected region.
>>
>> The Problem:
>>
>> The GDI library comes standard with several rectangular transformations -
>> stretch, Skew, etc.. But these apply only to a perfect rectangular region
>> where all points are perpendicular to each other.
>>
>> I have no problems in selecting the non-rectangular region - this is
>> easy.
>> I'm stumped at trying to work out how to take this region and applying
>> the
>> Photoshop like Distort Transformation.
>>
>> Anyone have any pointers?
>>
>> Thanks in advance...
>>
>> Graeme
>>
>>
>
>
Author
26 Jan 2007 11:01 PM
Kevin Spencer
Yes, I have a good understanding of what you're trying to do. The Bob Powell
and CodeProject references were just for the purpose of general information
about Matrices. The other 2 references are more specific, one of which goes
well into the mathematics, and one of which provides some samples of C#
Matrix math algorithms, although you will still have to create your own
matrices to do the work. But it WILL involve using Matrix transformation,
and you will have to figure out the Math.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

Show quoteHide quote
"GraGra33" <gragr***@hotmail.com> wrote in message
news:uAudhuZQHHA.2256@TK2MSFTNGP02.phx.gbl...
> Hi...
>
> Thanks for your suggestions - I've had a look at all the links mentioned.
> Bob's and the CodeProject artile I've already looked at both and they deal
> with rectangular regions (simple transformation) and not 4-point polygons
> (complex transformation).
>
> I've also looked at Gimp and Paint.Net - both only deal with regions
> (simple transformation)  and don't have Photoshop's distort transformation
> (complex transformation).
>
> I'm trying to do 4-point polygons (complex transformation) and not
> rectangular regions (simple transformation). The GDI+ matrix
> transformations only handle rectangular regions (simple transformation) as
> far as I can ascertain.
>
> To clarify what I'm trying to do, I'll give you another example - can send
> you a sample image if you think that you know how it's done.
>
> Example: The bottom-left and top-right corners are not squared to the
> Top-left & bottom-right corners. To square the image, the top-left and
> bottom-right must stay anchored whilst the bottom-left must be distorted
> towards the top and the top-right corner must be distorted to the right.
>
> Be aware that no two photos are the same and each photo will require
> different distort transformation adjustments.
>
> Do you still think that your suggestion will work or do you have another
> idea?
>
> Thanks for your help in advance,
>
> Graeme
>
> "Kevin Spencer" <unclechut***@nothinks.com> wrote in message
> news:e2CH2AUQHHA.1200@TK2MSFTNGP02.phx.gbl...
>> Transformations are all done using Matrix math. This is not going to be
>> an easy task, because you will have to understand Matrix math to do it.
>> Here are some articles and sample code to get you started:
>>
>> http://www.bobpowell.net/transformations.htm
>> http://www.codeproject.com/csharp/matrix_transformation.asp
>> http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
>> http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Software Composer
>> http://unclechutney.blogspot.com
>>
>> The shortest distance between 2 points is a curve.
>>
>> "GraGra33" <gragr***@hotmail.com> wrote in message
>> news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>> Hi all...
>>>
>>> I have developed an application for managing a very large resource of
>>> artist's paintings and posts them to a web site. The application works
>>> well.
>>> I'm trying to reduce the complexity of having to work with photoshop and
>>> integrate one feature into the application > Distortion Transformations.
>>>
>>> Background Information:
>>>
>>> When paintings are photographed, it's impossible to get a completely
>>> perfect
>>> image that requires straightening prior to cropping for a number of
>>> rasons -
>>> the photographer is not standing square on to the painting, the painting
>>> is
>>> leaning, the camera is not at the correct height,  the camera causes
>>> barrel
>>> distortion, etc...
>>>
>>> Therefore each image must be loaded into photoshop, all 4 corners
>>> selected
>>> using the polygonal lasso tool then manually applying a Distort
>>> Transformation (Edit > Transform > Distort) on the selected region.
>>>
>>> The Problem:
>>>
>>> The GDI library comes standard with several rectangular
>>> transformations -
>>> stretch, Skew, etc.. But these apply only to a perfect rectangular
>>> region
>>> where all points are perpendicular to each other.
>>>
>>> I have no problems in selecting the non-rectangular region - this is
>>> easy.
>>> I'm stumped at trying to work out how to take this region and applying
>>> the
>>> Photoshop like Distort Transformation.
>>>
>>> Anyone have any pointers?
>>>
>>> Thanks in advance...
>>>
>>> Graeme
>>>
>>>
>>
>>
>
>
Author
26 Jan 2007 10:44 PM
GraGra33
Hi...

Thanks for your suggestions - I've had a look at all the links mentioned.
Bob's and the CodeProject artile I've already looked at both and they deal
with rectangular regions (simple transformation) and not 4-point polygons
(complex transformation).

I've also looked at Gimp and Paint.Net - both only deal with regions (simple
transformation)  and don't have Photoshop's distort transformation (complex
transformation).

I'm trying to do 4-point polygons (complex transformation) and not
rectangular regions (simple transformation). The GDI+ matrix transformations
only handle rectangular regions (simple transformation) as far as I can
ascertain.

To clarify what I'm trying to do, I'll give you another example - can send
you a sample image if you think that you know how it's done.

Example: The bottom-left and top-right corners are not squared to the
Top-left & bottom-right corners. To square the image, the top-left and
bottom-right must stay anchored whilst the bottom-left must be distorted
towards the top and the top-right corner must be distorted to the right.

Be aware that no two photos are the same and each photo will require
different distort transformation adjustments.

Do you still think that your suggestion will work or do you have another
idea?

Thanks for your help in advance,

Graeme

Show quoteHide quote
"Kevin Spencer" <unclechut***@nothinks.com> wrote in message
news:e2CH2AUQHHA.1200@TK2MSFTNGP02.phx.gbl...
> Transformations are all done using Matrix math. This is not going to be an
> easy task, because you will have to understand Matrix math to do it. Here
> are some articles and sample code to get you started:
>
> http://www.bobpowell.net/transformations.htm
> http://www.codeproject.com/csharp/matrix_transformation.asp
> http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
> http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Software Composer
> http://unclechutney.blogspot.com
>
> The shortest distance between 2 points is a curve.
>
> "GraGra33" <gragr***@hotmail.com> wrote in message
> news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
>> Hi all...
>>
>> I have developed an application for managing a very large resource of
>> artist's paintings and posts them to a web site. The application works
>> well.
>> I'm trying to reduce the complexity of having to work with photoshop and
>> integrate one feature into the application > Distortion Transformations.
>>
>> Background Information:
>>
>> When paintings are photographed, it's impossible to get a completely
>> perfect
>> image that requires straightening prior to cropping for a number of
>> rasons -
>> the photographer is not standing square on to the painting, the painting
>> is
>> leaning, the camera is not at the correct height,  the camera causes
>> barrel
>> distortion, etc...
>>
>> Therefore each image must be loaded into photoshop, all 4 corners
>> selected
>> using the polygonal lasso tool then manually applying a Distort
>> Transformation (Edit > Transform > Distort) on the selected region.
>>
>> The Problem:
>>
>> The GDI library comes standard with several rectangular transformations -
>> stretch, Skew, etc.. But these apply only to a perfect rectangular region
>> where all points are perpendicular to each other.
>>
>> I have no problems in selecting the non-rectangular region - this is
>> easy.
>> I'm stumped at trying to work out how to take this region and applying
>> the
>> Photoshop like Distort Transformation.
>>
>> Anyone have any pointers?
>>
>> Thanks in advance...
>>
>> Graeme
>>
>>
>
>
Author
26 Jan 2007 11:01 PM
Kevin Spencer
Yes, I have a good understanding of what you're trying to do. The Bob Powell
and CodeProject references were just for the purpose of general information
about Matrices. The other 2 references are more specific, one of which goes
well into the mathematics, and one of which provides some samples of C#
Matrix math algorithms, although you will still have to create your own
matrices to do the work. But it WILL involve using Matrix transformation,
and you will have to figure out the Math.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

Show quoteHide quote
"GraGra33" <gragr***@hotmail.com> wrote in message
news:uAudhuZQHHA.2256@TK2MSFTNGP02.phx.gbl...
> Hi...
>
> Thanks for your suggestions - I've had a look at all the links mentioned.
> Bob's and the CodeProject artile I've already looked at both and they deal
> with rectangular regions (simple transformation) and not 4-point polygons
> (complex transformation).
>
> I've also looked at Gimp and Paint.Net - both only deal with regions
> (simple transformation)  and don't have Photoshop's distort transformation
> (complex transformation).
>
> I'm trying to do 4-point polygons (complex transformation) and not
> rectangular regions (simple transformation). The GDI+ matrix
> transformations only handle rectangular regions (simple transformation) as
> far as I can ascertain.
>
> To clarify what I'm trying to do, I'll give you another example - can send
> you a sample image if you think that you know how it's done.
>
> Example: The bottom-left and top-right corners are not squared to the
> Top-left & bottom-right corners. To square the image, the top-left and
> bottom-right must stay anchored whilst the bottom-left must be distorted
> towards the top and the top-right corner must be distorted to the right.
>
> Be aware that no two photos are the same and each photo will require
> different distort transformation adjustments.
>
> Do you still think that your suggestion will work or do you have another
> idea?
>
> Thanks for your help in advance,
>
> Graeme
>
> "Kevin Spencer" <unclechut***@nothinks.com> wrote in message
> news:e2CH2AUQHHA.1200@TK2MSFTNGP02.phx.gbl...
>> Transformations are all done using Matrix math. This is not going to be
>> an easy task, because you will have to understand Matrix math to do it.
>> Here are some articles and sample code to get you started:
>>
>> http://www.bobpowell.net/transformations.htm
>> http://www.codeproject.com/csharp/matrix_transformation.asp
>> http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
>> http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Software Composer
>> http://unclechutney.blogspot.com
>>
>> The shortest distance between 2 points is a curve.
>>
>> "GraGra33" <gragr***@hotmail.com> wrote in message
>> news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>> Hi all...
>>>
>>> I have developed an application for managing a very large resource of
>>> artist's paintings and posts them to a web site. The application works
>>> well.
>>> I'm trying to reduce the complexity of having to work with photoshop and
>>> integrate one feature into the application > Distortion Transformations.
>>>
>>> Background Information:
>>>
>>> When paintings are photographed, it's impossible to get a completely
>>> perfect
>>> image that requires straightening prior to cropping for a number of
>>> rasons -
>>> the photographer is not standing square on to the painting, the painting
>>> is
>>> leaning, the camera is not at the correct height,  the camera causes
>>> barrel
>>> distortion, etc...
>>>
>>> Therefore each image must be loaded into photoshop, all 4 corners
>>> selected
>>> using the polygonal lasso tool then manually applying a Distort
>>> Transformation (Edit > Transform > Distort) on the selected region.
>>>
>>> The Problem:
>>>
>>> The GDI library comes standard with several rectangular
>>> transformations -
>>> stretch, Skew, etc.. But these apply only to a perfect rectangular
>>> region
>>> where all points are perpendicular to each other.
>>>
>>> I have no problems in selecting the non-rectangular region - this is
>>> easy.
>>> I'm stumped at trying to work out how to take this region and applying
>>> the
>>> Photoshop like Distort Transformation.
>>>
>>> Anyone have any pointers?
>>>
>>> Thanks in advance...
>>>
>>> Graeme
>>>
>>>
>>
>>
>
>
Author
26 Jan 2007 11:13 PM
GraGra33
Thanks for the quick response Kevin.

I've had a good look at GDI+ and Matricies through alot of hand coding and
all I get are simple transformations. I fail to see how GDI+ can handle
complex transformations other than rectangular regions.

Kind Regards,

Graeme

Show quoteHide quote
"Kevin Spencer" <unclechut***@nothinks.com> wrote in message
news:uC4Sm3ZQHHA.4744@TK2MSFTNGP02.phx.gbl...
> Yes, I have a good understanding of what you're trying to do. The Bob
> Powell and CodeProject references were just for the purpose of general
> information about Matrices. The other 2 references are more specific, one
> of which goes well into the mathematics, and one of which provides some
> samples of C# Matrix math algorithms, although you will still have to
> create your own matrices to do the work. But it WILL involve using Matrix
> transformation, and you will have to figure out the Math.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Software Composer
> http://unclechutney.blogspot.com
>
> The shortest distance between 2 points is a curve.
>
> "GraGra33" <gragr***@hotmail.com> wrote in message
> news:uAudhuZQHHA.2256@TK2MSFTNGP02.phx.gbl...
>> Hi...
>>
>> Thanks for your suggestions - I've had a look at all the links mentioned.
>> Bob's and the CodeProject artile I've already looked at both and they
>> deal with rectangular regions (simple transformation) and not 4-point
>> polygons (complex transformation).
>>
>> I've also looked at Gimp and Paint.Net - both only deal with regions
>> (simple transformation)  and don't have Photoshop's distort
>> transformation (complex transformation).
>>
>> I'm trying to do 4-point polygons (complex transformation) and not
>> rectangular regions (simple transformation). The GDI+ matrix
>> transformations only handle rectangular regions (simple transformation)
>> as far as I can ascertain.
>>
>> To clarify what I'm trying to do, I'll give you another example - can
>> send you a sample image if you think that you know how it's done.
>>
>> Example: The bottom-left and top-right corners are not squared to the
>> Top-left & bottom-right corners. To square the image, the top-left and
>> bottom-right must stay anchored whilst the bottom-left must be distorted
>> towards the top and the top-right corner must be distorted to the right.
>>
>> Be aware that no two photos are the same and each photo will require
>> different distort transformation adjustments.
>>
>> Do you still think that your suggestion will work or do you have another
>> idea?
>>
>> Thanks for your help in advance,
>>
>> Graeme
>>
>> "Kevin Spencer" <unclechut***@nothinks.com> wrote in message
>> news:e2CH2AUQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>> Transformations are all done using Matrix math. This is not going to be
>>> an easy task, because you will have to understand Matrix math to do it.
>>> Here are some articles and sample code to get you started:
>>>
>>> http://www.bobpowell.net/transformations.htm
>>> http://www.codeproject.com/csharp/matrix_transformation.asp
>>> http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
>>> http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm
>>>
>>> --
>>> HTH,
>>>
>>> Kevin Spencer
>>> Microsoft MVP
>>> Software Composer
>>> http://unclechutney.blogspot.com
>>>
>>> The shortest distance between 2 points is a curve.
>>>
>>> "GraGra33" <gragr***@hotmail.com> wrote in message
>>> news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>>> Hi all...
>>>>
>>>> I have developed an application for managing a very large resource of
>>>> artist's paintings and posts them to a web site. The application works
>>>> well.
>>>> I'm trying to reduce the complexity of having to work with photoshop
>>>> and
>>>> integrate one feature into the application > Distortion
>>>> Transformations.
>>>>
>>>> Background Information:
>>>>
>>>> When paintings are photographed, it's impossible to get a completely
>>>> perfect
>>>> image that requires straightening prior to cropping for a number of
>>>> rasons -
>>>> the photographer is not standing square on to the painting, the
>>>> painting is
>>>> leaning, the camera is not at the correct height,  the camera causes
>>>> barrel
>>>> distortion, etc...
>>>>
>>>> Therefore each image must be loaded into photoshop, all 4 corners
>>>> selected
>>>> using the polygonal lasso tool then manually applying a Distort
>>>> Transformation (Edit > Transform > Distort) on the selected region.
>>>>
>>>> The Problem:
>>>>
>>>> The GDI library comes standard with several rectangular
>>>> transformations -
>>>> stretch, Skew, etc.. But these apply only to a perfect rectangular
>>>> region
>>>> where all points are perpendicular to each other.
>>>>
>>>> I have no problems in selecting the non-rectangular region - this is
>>>> easy.
>>>> I'm stumped at trying to work out how to take this region and applying
>>>> the
>>>> Photoshop like Distort Transformation.
>>>>
>>>> Anyone have any pointers?
>>>>
>>>> Thanks in advance...
>>>>
>>>> Graeme
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
29 Jan 2007 2:44 PM
Kevin Spencer
My point was not about GDI+ as such, but that you need to use Matrix math to
do your transform. In fact, the DirectX library has a matrix class that has
quite a bit of functionality built in, and is completely configurable, which
may be useful to you, or provide you with the knowledge you need to do your
transform. I might mention that what you need is not an affine transform,
which does not provide distortion. What you need to understand is that a
matrix provides a vector-based translation method, so what you need to do is
an orthagonal transform, to change the angle of the corners of your
rectangle. See
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_m/directx/ref/ns/microsoft.directx/s/matrix/matrix.asp.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

Show quoteHide quote
"GraGra33" <gragr***@hotmail.com> wrote in message
news:ui9tO%23ZQHHA.3460@TK2MSFTNGP03.phx.gbl...
> Thanks for the quick response Kevin.
>
> I've had a good look at GDI+ and Matricies through alot of hand coding and
> all I get are simple transformations. I fail to see how GDI+ can handle
> complex transformations other than rectangular regions.
>
> Kind Regards,
>
> Graeme
>
> "Kevin Spencer" <unclechut***@nothinks.com> wrote in message
> news:uC4Sm3ZQHHA.4744@TK2MSFTNGP02.phx.gbl...
>> Yes, I have a good understanding of what you're trying to do. The Bob
>> Powell and CodeProject references were just for the purpose of general
>> information about Matrices. The other 2 references are more specific, one
>> of which goes well into the mathematics, and one of which provides some
>> samples of C# Matrix math algorithms, although you will still have to
>> create your own matrices to do the work. But it WILL involve using Matrix
>> transformation, and you will have to figure out the Math.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Software Composer
>> http://unclechutney.blogspot.com
>>
>> The shortest distance between 2 points is a curve.
>>
>> "GraGra33" <gragr***@hotmail.com> wrote in message
>> news:uAudhuZQHHA.2256@TK2MSFTNGP02.phx.gbl...
>>> Hi...
>>>
>>> Thanks for your suggestions - I've had a look at all the links
>>> mentioned. Bob's and the CodeProject artile I've already looked at both
>>> and they deal with rectangular regions (simple transformation) and not
>>> 4-point polygons (complex transformation).
>>>
>>> I've also looked at Gimp and Paint.Net - both only deal with regions
>>> (simple transformation)  and don't have Photoshop's distort
>>> transformation (complex transformation).
>>>
>>> I'm trying to do 4-point polygons (complex transformation) and not
>>> rectangular regions (simple transformation). The GDI+ matrix
>>> transformations only handle rectangular regions (simple transformation)
>>> as far as I can ascertain.
>>>
>>> To clarify what I'm trying to do, I'll give you another example - can
>>> send you a sample image if you think that you know how it's done.
>>>
>>> Example: The bottom-left and top-right corners are not squared to the
>>> Top-left & bottom-right corners. To square the image, the top-left and
>>> bottom-right must stay anchored whilst the bottom-left must be distorted
>>> towards the top and the top-right corner must be distorted to the right.
>>>
>>> Be aware that no two photos are the same and each photo will require
>>> different distort transformation adjustments.
>>>
>>> Do you still think that your suggestion will work or do you have another
>>> idea?
>>>
>>> Thanks for your help in advance,
>>>
>>> Graeme
>>>
>>> "Kevin Spencer" <unclechut***@nothinks.com> wrote in message
>>> news:e2CH2AUQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>>> Transformations are all done using Matrix math. This is not going to be
>>>> an easy task, because you will have to understand Matrix math to do it.
>>>> Here are some articles and sample code to get you started:
>>>>
>>>> http://www.bobpowell.net/transformations.htm
>>>> http://www.codeproject.com/csharp/matrix_transformation.asp
>>>> http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
>>>> http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm
>>>>
>>>> --
>>>> HTH,
>>>>
>>>> Kevin Spencer
>>>> Microsoft MVP
>>>> Software Composer
>>>> http://unclechutney.blogspot.com
>>>>
>>>> The shortest distance between 2 points is a curve.
>>>>
>>>> "GraGra33" <gragr***@hotmail.com> wrote in message
>>>> news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>>>> Hi all...
>>>>>
>>>>> I have developed an application for managing a very large resource of
>>>>> artist's paintings and posts them to a web site. The application works
>>>>> well.
>>>>> I'm trying to reduce the complexity of having to work with photoshop
>>>>> and
>>>>> integrate one feature into the application > Distortion
>>>>> Transformations.
>>>>>
>>>>> Background Information:
>>>>>
>>>>> When paintings are photographed, it's impossible to get a completely
>>>>> perfect
>>>>> image that requires straightening prior to cropping for a number of
>>>>> rasons -
>>>>> the photographer is not standing square on to the painting, the
>>>>> painting is
>>>>> leaning, the camera is not at the correct height,  the camera causes
>>>>> barrel
>>>>> distortion, etc...
>>>>>
>>>>> Therefore each image must be loaded into photoshop, all 4 corners
>>>>> selected
>>>>> using the polygonal lasso tool then manually applying a Distort
>>>>> Transformation (Edit > Transform > Distort) on the selected region.
>>>>>
>>>>> The Problem:
>>>>>
>>>>> The GDI library comes standard with several rectangular
>>>>> transformations -
>>>>> stretch, Skew, etc.. But these apply only to a perfect rectangular
>>>>> region
>>>>> where all points are perpendicular to each other.
>>>>>
>>>>> I have no problems in selecting the non-rectangular region - this is
>>>>> easy.
>>>>> I'm stumped at trying to work out how to take this region and applying
>>>>> the
>>>>> Photoshop like Distort Transformation.
>>>>>
>>>>> Anyone have any pointers?
>>>>>
>>>>> Thanks in advance...
>>>>>
>>>>> Graeme
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
26 Jan 2007 11:13 PM
GraGra33
Thanks for the quick response Kevin.

I've had a good look at GDI+ and Matricies through alot of hand coding and
all I get are simple transformations. I fail to see how GDI+ can handle
complex transformations other than rectangular regions.

Kind Regards,

Graeme

Show quoteHide quote
"Kevin Spencer" <unclechut***@nothinks.com> wrote in message
news:uC4Sm3ZQHHA.4744@TK2MSFTNGP02.phx.gbl...
> Yes, I have a good understanding of what you're trying to do. The Bob
> Powell and CodeProject references were just for the purpose of general
> information about Matrices. The other 2 references are more specific, one
> of which goes well into the mathematics, and one of which provides some
> samples of C# Matrix math algorithms, although you will still have to
> create your own matrices to do the work. But it WILL involve using Matrix
> transformation, and you will have to figure out the Math.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> Software Composer
> http://unclechutney.blogspot.com
>
> The shortest distance between 2 points is a curve.
>
> "GraGra33" <gragr***@hotmail.com> wrote in message
> news:uAudhuZQHHA.2256@TK2MSFTNGP02.phx.gbl...
>> Hi...
>>
>> Thanks for your suggestions - I've had a look at all the links mentioned.
>> Bob's and the CodeProject artile I've already looked at both and they
>> deal with rectangular regions (simple transformation) and not 4-point
>> polygons (complex transformation).
>>
>> I've also looked at Gimp and Paint.Net - both only deal with regions
>> (simple transformation)  and don't have Photoshop's distort
>> transformation (complex transformation).
>>
>> I'm trying to do 4-point polygons (complex transformation) and not
>> rectangular regions (simple transformation). The GDI+ matrix
>> transformations only handle rectangular regions (simple transformation)
>> as far as I can ascertain.
>>
>> To clarify what I'm trying to do, I'll give you another example - can
>> send you a sample image if you think that you know how it's done.
>>
>> Example: The bottom-left and top-right corners are not squared to the
>> Top-left & bottom-right corners. To square the image, the top-left and
>> bottom-right must stay anchored whilst the bottom-left must be distorted
>> towards the top and the top-right corner must be distorted to the right.
>>
>> Be aware that no two photos are the same and each photo will require
>> different distort transformation adjustments.
>>
>> Do you still think that your suggestion will work or do you have another
>> idea?
>>
>> Thanks for your help in advance,
>>
>> Graeme
>>
>> "Kevin Spencer" <unclechut***@nothinks.com> wrote in message
>> news:e2CH2AUQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>> Transformations are all done using Matrix math. This is not going to be
>>> an easy task, because you will have to understand Matrix math to do it.
>>> Here are some articles and sample code to get you started:
>>>
>>> http://www.bobpowell.net/transformations.htm
>>> http://www.codeproject.com/csharp/matrix_transformation.asp
>>> http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
>>> http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm
>>>
>>> --
>>> HTH,
>>>
>>> Kevin Spencer
>>> Microsoft MVP
>>> Software Composer
>>> http://unclechutney.blogspot.com
>>>
>>> The shortest distance between 2 points is a curve.
>>>
>>> "GraGra33" <gragr***@hotmail.com> wrote in message
>>> news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>>> Hi all...
>>>>
>>>> I have developed an application for managing a very large resource of
>>>> artist's paintings and posts them to a web site. The application works
>>>> well.
>>>> I'm trying to reduce the complexity of having to work with photoshop
>>>> and
>>>> integrate one feature into the application > Distortion
>>>> Transformations.
>>>>
>>>> Background Information:
>>>>
>>>> When paintings are photographed, it's impossible to get a completely
>>>> perfect
>>>> image that requires straightening prior to cropping for a number of
>>>> rasons -
>>>> the photographer is not standing square on to the painting, the
>>>> painting is
>>>> leaning, the camera is not at the correct height,  the camera causes
>>>> barrel
>>>> distortion, etc...
>>>>
>>>> Therefore each image must be loaded into photoshop, all 4 corners
>>>> selected
>>>> using the polygonal lasso tool then manually applying a Distort
>>>> Transformation (Edit > Transform > Distort) on the selected region.
>>>>
>>>> The Problem:
>>>>
>>>> The GDI library comes standard with several rectangular
>>>> transformations -
>>>> stretch, Skew, etc.. But these apply only to a perfect rectangular
>>>> region
>>>> where all points are perpendicular to each other.
>>>>
>>>> I have no problems in selecting the non-rectangular region - this is
>>>> easy.
>>>> I'm stumped at trying to work out how to take this region and applying
>>>> the
>>>> Photoshop like Distort Transformation.
>>>>
>>>> Anyone have any pointers?
>>>>
>>>> Thanks in advance...
>>>>
>>>> Graeme
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
29 Jan 2007 2:44 PM
Kevin Spencer
My point was not about GDI+ as such, but that you need to use Matrix math to
do your transform. In fact, the DirectX library has a matrix class that has
quite a bit of functionality built in, and is completely configurable, which
may be useful to you, or provide you with the knowledge you need to do your
transform. I might mention that what you need is not an affine transform,
which does not provide distortion. What you need to understand is that a
matrix provides a vector-based translation method, so what you need to do is
an orthagonal transform, to change the angle of the corners of your
rectangle. See
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_m/directx/ref/ns/microsoft.directx/s/matrix/matrix.asp.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

The shortest distance between 2 points is a curve.

Show quoteHide quote
"GraGra33" <gragr***@hotmail.com> wrote in message
news:ui9tO%23ZQHHA.3460@TK2MSFTNGP03.phx.gbl...
> Thanks for the quick response Kevin.
>
> I've had a good look at GDI+ and Matricies through alot of hand coding and
> all I get are simple transformations. I fail to see how GDI+ can handle
> complex transformations other than rectangular regions.
>
> Kind Regards,
>
> Graeme
>
> "Kevin Spencer" <unclechut***@nothinks.com> wrote in message
> news:uC4Sm3ZQHHA.4744@TK2MSFTNGP02.phx.gbl...
>> Yes, I have a good understanding of what you're trying to do. The Bob
>> Powell and CodeProject references were just for the purpose of general
>> information about Matrices. The other 2 references are more specific, one
>> of which goes well into the mathematics, and one of which provides some
>> samples of C# Matrix math algorithms, although you will still have to
>> create your own matrices to do the work. But it WILL involve using Matrix
>> transformation, and you will have to figure out the Math.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Software Composer
>> http://unclechutney.blogspot.com
>>
>> The shortest distance between 2 points is a curve.
>>
>> "GraGra33" <gragr***@hotmail.com> wrote in message
>> news:uAudhuZQHHA.2256@TK2MSFTNGP02.phx.gbl...
>>> Hi...
>>>
>>> Thanks for your suggestions - I've had a look at all the links
>>> mentioned. Bob's and the CodeProject artile I've already looked at both
>>> and they deal with rectangular regions (simple transformation) and not
>>> 4-point polygons (complex transformation).
>>>
>>> I've also looked at Gimp and Paint.Net - both only deal with regions
>>> (simple transformation)  and don't have Photoshop's distort
>>> transformation (complex transformation).
>>>
>>> I'm trying to do 4-point polygons (complex transformation) and not
>>> rectangular regions (simple transformation). The GDI+ matrix
>>> transformations only handle rectangular regions (simple transformation)
>>> as far as I can ascertain.
>>>
>>> To clarify what I'm trying to do, I'll give you another example - can
>>> send you a sample image if you think that you know how it's done.
>>>
>>> Example: The bottom-left and top-right corners are not squared to the
>>> Top-left & bottom-right corners. To square the image, the top-left and
>>> bottom-right must stay anchored whilst the bottom-left must be distorted
>>> towards the top and the top-right corner must be distorted to the right.
>>>
>>> Be aware that no two photos are the same and each photo will require
>>> different distort transformation adjustments.
>>>
>>> Do you still think that your suggestion will work or do you have another
>>> idea?
>>>
>>> Thanks for your help in advance,
>>>
>>> Graeme
>>>
>>> "Kevin Spencer" <unclechut***@nothinks.com> wrote in message
>>> news:e2CH2AUQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>>> Transformations are all done using Matrix math. This is not going to be
>>>> an easy task, because you will have to understand Matrix math to do it.
>>>> Here are some articles and sample code to get you started:
>>>>
>>>> http://www.bobpowell.net/transformations.htm
>>>> http://www.codeproject.com/csharp/matrix_transformation.asp
>>>> http://www.euclideanspace.com/maths/algebra/matrix/arithmetic/index.htm
>>>> http://www.euclideanspace.com/maths/algebra/matrix/code/sftranslation_csharp.htm
>>>>
>>>> --
>>>> HTH,
>>>>
>>>> Kevin Spencer
>>>> Microsoft MVP
>>>> Software Composer
>>>> http://unclechutney.blogspot.com
>>>>
>>>> The shortest distance between 2 points is a curve.
>>>>
>>>> "GraGra33" <gragr***@hotmail.com> wrote in message
>>>> news:e90GZdTQHHA.1200@TK2MSFTNGP02.phx.gbl...
>>>>> Hi all...
>>>>>
>>>>> I have developed an application for managing a very large resource of
>>>>> artist's paintings and posts them to a web site. The application works
>>>>> well.
>>>>> I'm trying to reduce the complexity of having to work with photoshop
>>>>> and
>>>>> integrate one feature into the application > Distortion
>>>>> Transformations.
>>>>>
>>>>> Background Information:
>>>>>
>>>>> When paintings are photographed, it's impossible to get a completely
>>>>> perfect
>>>>> image that requires straightening prior to cropping for a number of
>>>>> rasons -
>>>>> the photographer is not standing square on to the painting, the
>>>>> painting is
>>>>> leaning, the camera is not at the correct height,  the camera causes
>>>>> barrel
>>>>> distortion, etc...
>>>>>
>>>>> Therefore each image must be loaded into photoshop, all 4 corners
>>>>> selected
>>>>> using the polygonal lasso tool then manually applying a Distort
>>>>> Transformation (Edit > Transform > Distort) on the selected region.
>>>>>
>>>>> The Problem:
>>>>>
>>>>> The GDI library comes standard with several rectangular
>>>>> transformations -
>>>>> stretch, Skew, etc.. But these apply only to a perfect rectangular
>>>>> region
>>>>> where all points are perpendicular to each other.
>>>>>
>>>>> I have no problems in selecting the non-rectangular region - this is
>>>>> easy.
>>>>> I'm stumped at trying to work out how to take this region and applying
>>>>> the
>>>>> Photoshop like Distort Transformation.
>>>>>
>>>>> Anyone have any pointers?
>>>>>
>>>>> Thanks in advance...
>>>>>
>>>>> Graeme
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

Bookmark and Share