Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Silverlight graphics
Let me explain you my project ............
Suppose i have circle or rectangle or eclipse or any shape in my image, i want to draw same shape inside it by keep specific distance.

Ex.i am having circle with 200pixel radius , now i want to draw another circle inside it by keeping 10pixel distance then the radius will be 190..Circle is regular shape and we have equation for it.

Suppose i am getting any other shape , and we don't have equation for it, Assume I am having "Cursive Letter" is drawn.

So what is my plan is to find tangent at all point of shape. from that i can draw same shape again with keeping inner distance..
Did i make seance to you.

If you have best solution then my then please share with me...
 

I want to find tangent at each pixel in image. NOTE: image is having white background and shape border color is block.
 
What i did is, Algo
 
While(true)
take pixel
if pixel color is black
make 3 X 3 matrix => fill the matrix by surrounding pixel color
...means assume white =0 and black=1 then keeping selected pixel
at center for 3 X 3 matrix and finding all other value;
----------------------------here i want to find tangent line to selected pixel;
end if
Move to next pixel.
End while
 

i want to achieve this,,,,,,,,,
https://picasaweb.google.com/108589415049574473159/November12012?authuser=0&authkey=Gv1sRgCKLg3P-qvcDt2QE&feat=directlink[^]
Posted 31-Oct-12 9:18am
Edited 31-Oct-12 10:55am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

"Tangent line" is something defined for a line, in case if the "line" is something defined by a function which has a derivative:
http://en.wikipedia.org/wiki/Tangent_line#Tangent_line_to_a_curve[^].
 
Your "find tangent" is even more confusing, as the primary meaning of tangent is this: http://en.wikipedia.org/wiki/Tangent[^].
 
Originally, the word is derived from Latin "touch". For example, there is a wonderful musical instrument called "tangent piano".
 
I have no idea how all this is related to what you want to calculate, because when you say "tangent line", you need to explain how this line is defined, line between what and what, etc. As pixel is not exactly a curve, the tangent line to a pixel does not seem to be a well-defined concept. A tangent line can be defined as a line "touching" another line, not an object like a geometrical point. As to the pixel, it's shape is considered to be undefined, conceptually. Smile | :)
 
I am ready to believe that the operation you want to perform makes sense, but you need to define things properly. I suspect that when you realize it and read the articles referenced above, you will be able to solve your problem by yourself. If not, formulate it properly and start over.
 
[EDIT: After OP's clarification:]
 
Please see the discussion in the comments to this post. The problem is not so simple. I know just one project where such operation is implemented explicitly:
http://en.wikipedia.org/wiki/InkScape[^],
http://inkscape.org/[^].
 
This is the source code:
http://inkscape.org/bzr.php?lang=en[^].
 
To download it, you will need Bazaar:
http://en.wikipedia.org/wiki/Bazaar_%28software%29[^],
http://bazaar.canonical.com/en/[^].
 
The product itself is just wonderful, and is practically a must-have anyway, in particular, for everyone who develops the UI. As you have the source code, you can see how the operation you need is done. In this editor, it's done very well. Just look at it, anyway.
 
Good luck,
—SA
  Permalink  
v2
Comments
Sergey Alexandrovich Kryukov at 31-Oct-12 16:16pm
   
[OP commented:]
 
Let me explain you my project ............
Suppose i have circle or rectangle or eclipse or any shape in my image, i want to draw same shape inside it by keep specific distance.

Ex.i am having circle with 200pixel radius , now i want to draw another circle inside it by keeping 10pixel distance then the radius will be 190..Circle is regular shape and we have equation for it.

Suppose i am getting any other shape , and we don't have equation for it, Assume I am having "Cursive Letter" is drawn.

So what is my plan is to find tangent at all point of shape. from that i can draw same shape again with keeping inner distance..
Did i make seance to you.

If you have best solution then my then please share with me...
Sergey Alexandrovich Kryukov at 31-Oct-12 16:18pm
   
Please, put it in the question using "Improve question", not a "solution".
You should have done this in first place.
--SA
Sergey Alexandrovich Kryukov at 31-Oct-12 16:21pm
   
I got it. Let me try to assure you that your original approach is wrong. And the formulation of it... I hope you can get it, what it is, looking at my answer.
For an arbitrary, let's say, closed shape, this problem is not as simple as you might think, needs thinking and good amount of work.
I know just one project where such thing is done, you can look at the source code.
--SA
Sergey Alexandrovich Kryukov at 31-Oct-12 16:28pm
   
So, please see the updated answer, after [EDIT].
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 BillWoodruff 360
1 Mathew Soji 309
2 DamithSL 225
3 Afzaal Ahmad Zeeshan 202
4 Maciej Los 190
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 31 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100