What is a viable method of spacing out text in visual studio - visual-studio

We are attempting to expand text in Visual Studio. Our current attempt consists of creating transparent intraline adornments at certain points in the text.
We have just stumbled upon a disadvantage to this method. Namely that when the given text has a background classification attached to it, the classification breaks and the result looks like this:
We are currently researching possible ways of solving this by:
Inspecting the current classification of the text and drawing a colored intraline adornment.
Drawing the background manually, by drawing in an adornment layer below the text.
However, both of these solutions seem very hacky.
What would be the best way of going about solving this problem?

You're asking how to hack around a standing limitation in the editor, so there isn't a great way :-/
My background color fix extension does what you're suggesting in #2, so you could start from there. I haven't tested it since VS2010 or so, so it may fail in interesting and exciting ways.

Related

Gamemaker Studio 2 bits randomly getting deleted

I am a student building a senior project in Gamemaker Studio for our capstone project as part of my Game Development concentration.
I am in charge of sprite creation, and currently, it is randomly deleting bits as I draw. So I will draw a couple of bits, and then it will randomly remove the surrounding bits of color. I am becoming increasingly irritated at this and I have no idea why this is happening. Any help would be greatly appreciated.
Effectively, I am designing a character and I'm trying to give his arms a bit more depth so I give him a few more tan-colored muscles. As I do, it erases the rest of his arm.
If you mean the Sprite Editor, then I recommend you using a different program for the sprites, as that one is completely garbage. I'm using Paint.net, its free and works in a similar way like the gms2 sprite editor but better. more plugins, more effects, better shortcut handlings.
If you still wanna stick to the gms2 sprite editor then I'll recommend restarting the game first. that's a problem I never had. Maybe you should check if you are drawing in different layers, and the blend modes of the layers. also maybe your brush is not just a pixel, but maybe a bigger brush.

Read text from a T-Shirt image

I am trying to read text from a t-Shirt image.
I tried tesserect but i dont get the proper text.
There seems to be lots of ways to read from a white/constant background.. but not from any random scene..
What is the recommended way to achieve this?
In this task you are facing same challenges as any other OCR project dealing with unconventional media (not paper scans) - variable colors, text on backgrounds, distortions in print surface, various angles, fonts, etc. Each potential aspect that affects OCR quality requires a separate methodology and process how to handle it, and when they all work together, good results can be achieved.
This Blog posting I wrote some time ago is a good place to start. It addresses nearly every issue you may face in your task.
http://www.ocr-it.com/user-scenario-process-digital-camera-pictures-and-ocr-to-extract-specific-numbers
Take a look at other articles in the same Blog.
Sample image would definitely help to answer with more specifics.

Is anyone aware of a visual diagram that shows the composite parts of std. Windows controls?

For example: I would like to know exactly what system metrics to use to know how wide the borders of a window are going to be. With a given set of visual styles, what borders will appear, and how wide will they be (what system metrics can be queried to know exactly and correctly how wide they'll be)?
Similarly, for a button, how wide are its borders in various states? Using different themes? What system metrics or theme functions can give me a absolutely correct answer on how wide, how tall, how many, what offsets?
Generally speaking, my custom interface code usually contains things like:
myrect.Offset(4,4); // empirical evidence indicates it's actually 4 more pixels per side that Windows adds in but doesn't tell me about...
I hate code like this - littered with magical numbers that may change depending on version of Windows, whether Aero is enabled or not, whether the customer is running this theme or that theme, or using large font / high DPI mode, or not, etc.
But I haven't, in my 15+ years of Windows GUI programming, ever seen a really good white paper or diagram or chart that describes the actual composition of all std. windows controls, and where their various visual parts' metrics come from.
Is anyone out there aware of a resource even similar to this? A white paper? A diagram? A detailed blog discussion? Anything?
Thanks for any help you may have!
EDIT: the GUI guidelines idea doesn't actually describe the internal composition of the controls visual parts - just their overall size and spacing between controls.
I really would love to have something that describes in excruciating detail the border sizes, offsets, and what system metrics control each of these things.
What about the Windows User Experience Interaction Guidelines? [Document Index] [PDF download]
It includes diagrams like this:
This is not a complete answer to your question, though, because it only tells you how the controls are supposed to be laid out, not how they actually are. And it doesn’t address what happens under different themes.

How do you crop an image in Expression Blend?

I know this is leaning more in the direction of a designer question, but as I am faced with developing something which requires me to crop an image, I thought I would give the question a shot.
This seems like a ridiculous question to ask, but I've look all over the IDE (Expression Blend 2) to try and find a way to crop my image, but I can't figure it out.
This seems to be very much in line with Joel's question and is discussed in Podcast 58 in the sense that I'm a complete noob when it comes to designing in Expression Blend. I am adamantly interested in figuring out the most efficient way to do this. I found an article that describes a work flow you can go through that will produce a crop, which I added as an answer below, but I'm really hoping someone else will know of a quicker (less clicks) way to do something as trivial as this.
Does anyone know how this can be done?
As far as I know, there's no way to crop an image directly in expression Blend. Blend is not an image editing application. You need another tool for that.
What you can do though, is clipping an image if you only want to show a portion of it. Just add a rectangle on top of it right-click it, go to path -> make clipping path.
alt text http://img200.imageshack.us/img200/7370/example1.jpg
Now select the System.Windows.Controls.Image entry from the list you want to apply the clipping on and hit Ok
You can even use rounded rectangles, circles and custom paths to clip, but in most cases a rectangle will do the trick.
Just ran into another way.
Have a look at this question. It uses a CroppedBitmapClass as the source of an image. It's not actual drawing in Blend, but you can add it by hand editing Xaml. From your question it's not clear if you are creating a Silverlight or a WPF application in Expression Blend. The CroppedBitmapClass is available in WPF only.
With the new Silverlight 3 you can use the WritableBitmap to do image cropping:
I found an article that has steps to do an image crop, but it's very drawn out to do such a simple operation. You would think something that MS Paint can do in a couple button clicks would be similarly easy in Blend.
Here's the link.
I'm still wondering if there's an easier way to do this, however.
The other problem with this approach is that afterwards, I can't change the size of the rectangle that I'm cropping the image with, which I need to be able to do, because I have to have the image be an exact number of pixels in width and height.

Dilemma about image cropping algorithm - is it possible?

I am building a web application using .NET 3.5 (ASP.NET, SQL Server, C#, WCF, WF, etc) and I have run into a major design dilemma. This is a uni project btw, but it is 100% up to me what I develop.
I need to design a system whereby I can take an image and automatically crop a certain object within it, without user input. So for example, cut out the car in a picture of a road. I've given this a lot of thought, and I can't see any feasible method. I guess this thread is to discuss the issues and feasibility of achieving this goal. Eventually, I would get the dimensions of a car (or whatever it may be), and then pass this into a 3d modelling app (custom) as parameters, to render a 3d model. This last step is a lot more feasible. It's the cropping issue which is an issue. I have thought of all sorts of ideas, like getting the colour of the car and then the outline around that colour. So if the car (example) is yellow, when there is a yellow pixel in the image, trace around it. But this would fail if there are two yellow cars in a photo.
Ideally, I would like the system to be completely automated. But I guess I can't have everything my way. Also, my skills are in what I mentioned above (.NET 3.5, SQL Server, AJAX, web design) as opposed to C++ but I would be open to any solution just to see the feasibility.
I also found this patent: US Patent 7034848 - System and method for automatically cropping graphical images
Thanks
This is one of the problems that needed to be solved to finish the DARPA Grand Challenge. Google video has a great presentation by the project lead from the winning team, where he talks about how they went about their solution, and how some of the other teams approached it. The relevant portion starts around 19:30 of the video, but it's a great talk, and the whole thing is worth a watch. Hopefully it gives you a good starting point for solving your problem.
What you are talking about is an open research problem, or even several research problems. One way to tackle this, is by image segmentation. If you can safely assume that there is one object of interest in the image, you can try a figure-ground segmentation algorithm. There are many such algorithms, and none of them are perfect. They usually output a segmentation mask: a binary image where the figure is white and the background is black. You would then find the bounding box of the figure, and use it to crop. The thing to remember is that none of the existing segmentation algorithm will give you what you want 100% of the time.
Alternatively, if you know ahead of time what specific type of object you need to crop (car, person, motorcycle), then you can try an object detection algorithm. Once again, there are many, and none of them are perfect either. On the other hand, some of them may work better than segmentation if your object of interest is on very cluttered background.
To summarize, if you wish to pursue this, you would have to read a fair number of computer vision papers, and try a fair number of different algorithms. You will also increase your chances of success if you constrain your problem domain as much as possible: for example restrict yourself to a small number of object categories, assume there is only one object of interest in an image, or restrict yourself to a certain type of scenes (nature, sea, etc.). Also keep in mind, that even the accuracy of state-of-the-art approaches to solving this type of problems has a lot of room for improvement.
And by the way, the choice of language or platform for this project is by far the least difficult part.
A method often used for face detection in images is through the use of a Haar classifier cascade. A classifier cascade can be trained to detect any objects, not just faces, but the ability of the classifier is highly dependent on the quality of the training data.
This paper by Viola and Jones explains how it works and how it can be optimised.
Although it is C++ you might want to take a look at the image processing libraries provided by the OpenCV project which include code to both train and use Haar cascades. You will need a set of car and non-car images to train a system!
Some of the best attempts I've see of this is using a large database of images to help understand the image you have. These days you have flickr, which is not only a giant corpus of images, but it's also tagged with meta-information about what the image is.
Some projects that do this are documented here:
http://blogs.zdnet.com/emergingtech/?p=629
Start with analyzing the images yourself. That way you can formulate the criteria on which to match the car. And you get to define what you cannot match.
If all cars have the same background, for example, it need not be that complex. But your example states a car on a street. There may be parked cars. Should they be recognized?
If you have access to MatLab, you could test your pattern recognition filters with specialized software like PRTools.
Wwhen I was studying (a long time ago:) I used Khoros Cantata and found that an edge filter can simplify the image greatly.
But again, first define the conditions on the input. If you don't do that you will not succeed because pattern recognition is really hard (think about how long it took to crack captcha's)
I did say photo, so this could be a black car with a black background. I did think of specifying the colour of the object, and then when that colour is found, trace around it (high level explanation). But, with a black object in a black background (no constrast in other words), it would be a very difficult task.
Better still, I've come across several sites with 3d models of cars. I could always use this, stick it into a 3d model, and render it.
A 3D model would be easier to work with, a real world photo much harder. It does suck :(
If I'm reading this right... This is where AI shines.
I think the "simplest" solution would be to use a neural-network based image recognition algorithm. Unless you know that the car will look the exact same in each picture, then that's pretty much the only way.
If it IS the exact same, then you can just search for the pixel pattern, and get the bounding rectangle, and just set the image border to the inner boundary of the rectangle.
I think that you will never get good results without a real user telling the program what to do. Think of it this way: how should your program decide when there is more than 1 interesting object present (for example: 2 cars)? what if the object you want is actually the mountain in the background? what if nothing of interest is inside the picture, thus nothing to select as the object to crop out? etc, etc...
With that said, if you can make assumptions like: only 1 object will be present, then you can have a go with using image recognition algorithms.
Now that I think of it. I recently got a lecture about artificial intelligence in robots and in robotic research techniques. Their research went on about language interaction, evolution, and language recognition. But in order to do that they also needed some simple image recognition algorithms to process the perceived environment. One of the tricks they used was to make a 3D plot of the image where x and y where the normal x and y axis and the z axis was the brightness of that particular point, then they used the same technique for red-green values, and blue-yellow. And lo and behold they had something (relatively) easy they could use to pick out the objects from the perceived environment.
(I'm terribly sorry, but I can't find a link to the nice charts they had that showed how it all worked).
Anyway, the point is that they were not interested (that much) in image recognition so they created something that worked good enough and used something less advanced and thus less time consuming, so it is possible to create something simple for this complex task.
Also any good image editing program has some kind of magic wand that will select, with the right amount of tweaking, the object of interest you point it on, maybe it's worth your time to look into that as well.
So, it basically will mean that you:
have to make some assumptions, otherwise it will fail terribly
will probably best be served with techniques from AI, and more specifically image recognition
can take a look at paint.NET and their algorithm for their magic wand
try to use the fact that a good photo will have the object of interest somewhere in the middle of the image
.. but i'm not saying that this is the solution for your problem, maybe something simpler can be used.
Oh, and I will continue to look for those links, they hold some really valuable information about this topic, but I can't promise anything.

Resources