Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I have been trying to find a code snippet to do an unsharp mask in C# but cant find one that works or is complete. I found a PHP version but I would like to find one in C# before I go through all the hard work converting this from PHP.
I am just a beginner. Can anyone point me in the right direction?
The AForge.NET Framework includes many image processing filters and support plugging your own. You can see it in action in their own Image Processing Lab application.
UPDATE: AForge.NET has a convolution-based sharpen filter (see convolution filters), but there's no mention of an unsharp mask filter per se. Then again, you can use the Gaussian blur filter and subtract the result from the original image, which is basically what the unsharp mask filter does. Or maybe the basic sharpen is enough for your needs.
UPDATE: Looked further, and AForge.NET does have a Gaussian sharpen which seems to be an implemenation of an unsharp mask filter, and you can control some parameters.
Would you care to use FFTs? Transform, remove or accentuate high freqs to taste, invert the transform, recombine with the original if desired? Hardly any licensing issues there, as FFT libraries abound.
Alternately, you can make up masks by hand, varying size and constants as you like, then convolve them with your image pixels (nested 'for' loops ...).
Here's a 3x3x1 mask as a text file with its dimensions given before the values:
//3x3x1
// x size
3
// y size
3
//z size
1
//z = 0
2 3 2
3 5 3
2 3 2
//end
This can be extended to 3 dimensions (hence the z size being given).
The latest version of the open source C# Image Library has an unsharp mask filter (as well as gaussian blur, brightness/contrast etc) and is very easy to use.
You'll find a tutorial how to apply an unsharp mask here.
See if this blog entry helps you in the right direction:
http://anand-vinay.blogspot.com/2008/01/unsharp-mask-in-cnet.html
Edit: Okay that blog entry did not work, sorry for the bad link.
I did find a complete application that you can download with source which has the code that I think you are looking for.
http://www.ctyeung.com/Csharp/index.html
Christian Graus's Image Processing for Dummies with C# part 2 contains source code, and an explanation of how you can do unsharpen (assuming you mean smoothing). The whole series is an excellent introduction to image processing with GDI (in C#) and requires no external libraries.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to create an application which is able to accurately measure the body parameters of a person like height, shoulder width and waist.
Currently I have been able to determine the height and the shoulder width of a person using skeletal tracking.
Can anybody help me out regarding how to measure the waist of a person using a Kinect!
I am coding in C# in Visual Studio.
Thanks a lot in advance!
It is hard to give you the exact code, right now, but the recipe:
First you need to understand what it entails. Every person has different proportions. Someone has a wide waist, but fit (athletic), someone has a wide waist, but has also big belly (fat figure), another has a wasp waist. Such variations are many and many...
So, you have to shoot waist in time during rotation around its axis. Then the measured width values convert to a model. After that you will read circumference of the waist plan (like from a blueprint).
EDIT:
Detailed:
If a person turns around (you know it, because the waist witdh values changes...front-left-back-rigth-front and many samples between each part of rotation) gives you the measures in time for the pattern.
Split whole time of rotation to number of samples. Each sample will determine the proportional angle of the turn. (8 samples per rotation means one sample is 45° [360°/8=45°]). Now imagine the circle. Split it into 8 circle chords. Each chord have length of the value measured during the rotation.
If the sample count is good enough, now you can reckon the circumference of the polygon. If the count of samples is too low, you can interpolate (or use another solution) the "missing" samples. The more samples you have, the more accurate result you have.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am new to image processing so please forgive my ignorance. I am trying the come up with a way to get the co-ordinates of a sub image inside that of its containing larger image. For example, I have a large image of the New York skyline and one of just the Empire State building. The large picture is always a high quality image, the small picture is supplied by a user's camera scanning a printed version of the larger image. There the quality, scale and colors of the smaller image will not perfectly match those of the larger one. What I am looking to get is X, Y coordinates from the top-left corner of the larger image, to the top-left corner of the smaller image as if the smaller image were a puzzle piece placed in the larger image. It would be much appreciated of someone could point me in the right direction. Thanks
EDIT
Thank you for the feedback. I have come to realize that this might be a very difficult task. I ended taking a different approach. I will be embedding recognizable shapes in the aforementioned print media and use OpenCvSharp (a free C# wrapper around OpenCV) to detect them.
to just give you one possible direction,
What you are might be facing here is a flavor of pattern detection and/or recognition (aka machine learning), I suggest look for ready implementations as this is complicated task.
The basic idea is that you train or teach an algorithm about features of objects of interest and then the algorithm searches in images for anything that matches your pattern.
There are many algorithms out there; each will have its own approach. As a starting point, You could try to look at what well known image processing framework can offer - OpenCV:
http://docs.opencv.org/2.4/doc/tutorials/features2d/feature_homography/feature_homography.html
EDIT :
OpenCV wrapper for .NET C# as OpenCV is C++ project
http://www.emgu.com/wiki/index.php/Main_Page
This is a very hard and big project to do.
BTW, You can get color of a pixel by GetPixel() method.
Following code creates a 200x200 image and get color of 100,100 coordination of that image.
Bitmap bmp = new Bitmap(200,200);
Color c = bmp.GetPixel(100,100);
For surfing image efficiently you must use pointer(unsafe code) not GetPixel() method unless the performance will be too slow.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I plan to write a program or rather function which will be able to analyze a string parameter which in turn will be math expression. Only the 4 basic operations are allowed(addition, subtraction, multiplication and division) and the numbers are all whole numbers from -100 to 100. The result is allowed to be float. I know the registries work in the same way I.e calculate result of two numbers and store it, than calculate result of stored value and the next operant and store. And so forth until there are no operands left. The number of operands will usually be 2 but I will have a need of 3 or even more so yes, more operands is a requirement.
I was wondering how would you structure this in C#? What tools helper functions you would use in this scenario?
Note: I am working on Unity 5.1.4 project and I want to use a math parser in it. Unity is .NET 2.0
Note: This seems most promising: http://mono.1490590.n4.nabble.com/Javascript-eval-function-in-c-td1490783.html
It uses a variant of eval() function.
In .NET there are no some high level helper functions to help you with this. You would have to parse and tokenize the string in your code. There are however third party libraries that do what you need, for instance Expression Compiler, Simple Math Parser, Mathos Parser, and many other. Search for math expression parser.
If you want to make one from scratch you could look the code of existing ones.
Hans Passant mentions a simple solution, maybe just what you need. You get the result of the expression, so if you need just that, and not the actual expression tokens, then .NET got you covered.
This tool finished the job with no adding external references, dlls or what not: http://mono.1490590.n4.nabble.com/Javascript-eval-function-in-c-td1490783.html
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I can't find for the life of me the correct names for interpolations like the ones below.
I am trying to look them up google using ease-in interpolation, types of interpolation, but without much luck.
All I want is to implement them in a fashion like this:
double Interp ( double value, double t )
where value is the value to be interpolated and t is the time value that can be any value between 0-1, including 0 and 1.
So if Interp was using a linear interpolation and value was 10, and t was 0.5, the return would be 5. But I want to get the values using other interpolations.
Any help on this?
I remember seeing a website with flash animations showing the formula of each one time but can't find it anymore.
I've heard this referred to as "easing" or "tweening".
http://robertpenner.com/easing/ has a Flash demo and links to a PDF file with the equations.
http://code.google.com/p/tweener/ has an ActionScript library to implement them, with links to ports in JavaScript, Python, C++, etc.
http://gsgd.co.uk/sandbox/jquery/easing/ is an easing plugin for jQuery.
Interpolation involves estimating a curve based on a set of inputs, the larger the set of inputs the better the curve estimation. Is this what you are trying to do here? This guys talks about linear and quadratic interpolation techniques. http://www.codeproject.com/KB/recipes/simple_interpolation.aspx. If you want some more specialised interpolation techniques we really need to know a little more about the shape of the curve you are trying to estimate
See: http://mathworld.wolfram.com/Interpolation.html
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Here is a sample of what I'm looking to reproduce.
I thought about tiling an image but that would create a detectable pattern.
I also thought about a random pattern using 4 or 5 colors but this is not a random pattern.
Thanks!
The military uses a fractal pattern called MARPAT, which I understand is highly effective compared to other known camo patterns. However, they have patented it, and I'm not aware of any way to find out the specifics.
Your best bet is probably Perlin noise, though I'm not sure how effective it would be as actual camouflage if you printed it out and tried to hide with it. You should be able to generate something that looks a lot like military camouflage, which is probably what you're trying to do.
What I would do:
choose a few colors for your camo
create a blank canvas
seed a number of points using your colors (change random pixels to a random color)
fill in the gaps using the algorithm below.
You want this to be random but you also want some clustering for those stripes/blobs in your example. So, by filling in the gaps from the seed points outwards, you can use the surrounding pixels to influence the color decision. If a pixel is surrounded by green, then it should be more likely to be green than yellow. So, for every pixel moving outwards from the seed points:
Consider your surrounding (8, 24, etc) pixels and use those to determine the chances for each color. Each color gets assigned a range of numbers between 0 and 1 (For example, green might be .23 - .57). The sum of the ranges should include all numbers between 0 and 1.
Use a random number generator to choose a number between 0 and 1. Whatever color range the number falls into is what color that pixel should be.
Find an adjacent blank pixel, repeat.
Totally untested, but it works in my head? Haha.
EDIT And if you'd like the larger boxes that digital camo actually has (as opposed to single pixels) group the pixels into groups of 9, 16, 25, 36, etc.
Try using Perlin Noise
Along the lines of Mr E's answer, if you want to go the procedural route, look at various fractal algorithms.
Here's a map generator that uses erosion, I could imagine you layering several of those and maybe skewing things horizontally for your image: http://forums.tigsource.com/index.php?topic=5174.180
There's all sorts of other pattern generators - simulating termites, forest fires, crystal growth, etc.
Here are some examples: http://neekatave.com/ca/examples/ffire/index.php
You will see links in there to Star Logo, which is an educational MIT project that has a bunch more examples (warning, you may lose a lot of time clicking around there :)