I have a treeview that contains icons. The icons are ugly. and by ugly i mean low quality. and by low quality i mean something i would expect to see from a dos program
i would hope there would be a way to improve the image quality of the icons, but after looking around on microsoft's development site, I have yet to find a solution.
to be honest, at this point i don't even know what to look for. 'image quality' is very too broad of a phrase to search for (i've gotten very random results from google searches).
i am using an ImageList to store these icons in the TreeView. there really isnt much code to show that would be of use here - at least i dont think so.
sorry for the boring question.
Is this what you're looking for?
http://msdn.microsoft.com/en-us/library/system.windows.forms.imagelist.colordepth.aspx
The default value is set to 8-bit, so changing this property of your list will probably help. Essentially, just add the following line to your code:
imagelist.ColorDepth = ColorDepth.Depth32Bit;
It can be improved. What you need to do is to open it in photoshop or gimp and resample it at 3 times it size. Then resample it at 600 dpi and resize it down to 8 x 10.
Notice, that I specified to resize and not down size. You click on the pic and the corners have a handle for you to click on and size it down to the appropraite size. This way, the pixels are closer together.
Then, you use a very soft blur, I mean really soft. The secret is when it is printed. We print at 600 to 1200 dpi which is what will enhance the picture and that is what a printer has to keep in mind. When you print on glossy paper at 600 dpi, the pic comes out really nice and sharp.
Related
I am developing a WPF C# video player with the MediaElement.
Some videos contain black bars at the top and bottom. I want to resize the picture i.e. to 120% so that no black bars are shown when I play these videos.
Now the question is how I can measure the size of the black bars. If i.e. a video has a height of 800 pixels I want to measure the height of the black bars. If there are 50 pixels black at the top and 50 pixels on the bottom then I will calculate that I have to resize the picture i.e. to 112%.
I guess I could make a screenshot of the video and then analyze that picture to find out how many black pixels are at the top and bottom (I have no idea how complicated that would be). But I guess and hope there is an easier way to do this. Any ideas?
This is the beginning of my answer: I just wrote a quick and dirty solution with the screenshot.
I used RenderTargetBitmap to create a screenshot with the height of the video but just 1 pixel wide. Then I used the BitmapSource.CopyPixels Method to extract the single pixels and then I looped through the pixels from top to bottom. It works, and it work fast enough for me (<30ms for the whole procedure).
I will publish the complete code when it’s done.
I am still interested if there is an easier way to do this. My own answer is just one answer but I am happy to accept something better as “the answer”.
I have an array of graphs, that are 2000x1000 pixels pngs. When I put them into a silverlight Image that auto-sized with the browser window, DisplayImage.Source = new BitmapImage(GetHeatmapURL()); they images look distorted and for some browser sizes much worse than for some others.
I want to fiddle with some setting that would improve the quality of this downsampling, is this possible? Am I doing something wrong? My first approach was to put the Image into a Viewbox. That looked even worse. Googling gives virtually nothing useful...
Any help much appreciated.
PS. I'm working with Silverlight 4.
You could check out the WriteableBitmapEx project on CodePlex which gives you a Resize() extension method for the Silverlight WritableBitmap class where you can use either Bilinear or Nearest Neighbor interpolation. Resizing with the Bilinear interpolation might give you something that looks better than the ViewBox resizing, but you would have to test it out.
var resized = writeableBmp.Resize(200, 300, WriteableBitmapExtensions.Interpolation.Bilinear);
When making use of the Viewbox you need to make sure to set Stretch to Uniform to respect the original height/width ratio.
In regards to the rendering of the image at the given aspect ratio and size; that is contingent on the framework.
I was wondering if anyone would give me pointers to image rec packages that would help me recognize "text" (not OCR, just something that looks like text) and a black box frame. So, suppose:
text
+----------+
| |
| text1 |
| |
| |
+----------+
text
How do I recognize that "text" boxes are text, and that, say, text1 is inside the box?
Apologies for the vague question... I wouldn't know where to start. This is not homework, btw.
[This is of interest to us.] I am assuming your input is effectively a bitmap - a rectangular matrix of pixels. The first question is whether it is aligned with the axes - if it's been scanned it's probably not. You may need deskewing algorithms (rather dated but it's a useful start: http://www.eecs.berkeley.edu/~fateman/kathey/node11.html)
The classic line detection is the Hough transform (http://en.wikipedia.org/wiki/Hough_transform) though our current collaborators do better than this for simple boxes and project pixels onto different viewpoints - similar to tomography. Rotate the image and count the density/histogram of points on the projection lines. For simple boxes that gives a clear signal.
For the text I suspect you either have to have a set of likely fonts or to use machine learning. In the latter you have to devise features and then select a series of images that are classified by humans as text and not-text. Your algorithm (and there are many, neural nets, maximum entropy, etc.) are then trained against these.
The quality of the pixel map makes a great deal of difference. Documents 20 years ago and much harder than bitmaps of documents created though drawing programs and dumped as PDF (of course if you can interpret text in PDF that helps a good deal.)
You can apply any border detection algorithm to detect box. and since color of text is different form the color of background you can use even linear search to find black pixels of 'text'. I may be wrong, sorry about that.
A very simple algorithm would to scan left-to-right and top-to-bottom, looking for the three black pixels that make up an upper-left corner of a box (and then continuing to scan for the three pixels that would make up the matching lower-right corner). Once you've identified each box in the image in this way, you could scan the inner portion and assume that any non-white pixels mean there is some text in the box. Of course, this would not differentiate between text and images inside the box, but that would be a much more difficult problem anyway.
I'm currently using a semi-transparent WPF form with no border as a camera style device in a program of mine. However, when I access the position (top, left) and dimension (height, width) properties of the form, it would appear they are wrong.
The top property reported to be roughly 26 pixels higher than it actually is in relation to the desktop. IE if I put the forms top and left at (0,0) the properties will report (0, -26).
The height is also incorrect, reporting about 50-60 pixels shorter than it actually is.
Has anybody experienced this problem in the past and have a solution?
Regards,
Andy Hunt
if I understand correctly, this is no problem at all but the expected behavior.
WPF uses DPI-independent virtual units for measuring size and position, not actual pixels.
There are many sources like this explaining this.
If I understood the question wrong (its late and I am tired ;) could you provide a code sample illustrating the issue?
Andrej
So here are the details (I am using C# BTW):
I receive a 32bpp image (JPEG compressed) from a server. At some point, I would like to use the Palette property of a bitmap to color over-saturated pixels (brightness > 240) red. To do so, I need to get the image into an indexed format.
I have tried converting the image to a GIF, but I get quality loss. I have tried creating a new bitmap in an index format by these methods:
// causes a "Parameter not valid" error
Bitmap indexed = new Bitmap(orig.Width, orig.Height, PixelFormat.Indexed)
// no error, but the resulting image is black due to information loss I assume
Bitmap indexed = new Bitmap(orig.Width, orig.Height, PixelFormat.Format8bppIndexed)
I am at a loss now. The data in this image is changed constantly by the user, so I don't want to manually set pixels that have a brightness > 240 if I can avoid it. If I can set the palette once when the image is created, my work is done. If I am going about this the wrong way to begin with please let me know.
EDIT: Thanks guys, here is some more detail on what I am attempting to accomplish.
We are scanning a tissue slide at high resolution (pathology application). I write the interface to the actual scanner. We use a line-scan camera. To test the line rate of the camera, the user scans a very small portion and looks at the image.
The image is displayed next to a track bar. When the user moves the track bar (adjusting line rate), I change the overall intensity of the image in an attempt to model what it would look like at the new line rate. I do this using an ImageAttributes and ColorMatrix object currently.
When the user adjusts the track bar, I adjust the matrix. This does not give me per pixel information, but the performance is very nice. I could use LockBits and some unsafe code here, but I would rather not rewrite it if possible. When the new image is created, I would like for all pixels with a brightness value of > 240 to be colored red. I was thinking that defining a palette for the bitmap up front would be a clean way of doing this.
Going from 32bpp to 8bpp indexed will almost always result in quality loss, unless the original image has less than 256 colors total.
Can you create another image that is a overlay with the affected pixels red, then show both of those?
Since you are going for brightness > 240, you can convert the overlay to grayscale first, then to indexed to get the overbright pixels.
You don't specify what you are doing with it once you have tagged the offenders, so I don't know if that will work.
Sounds like something you could do easily with a pixel shader. Even very early shader models would support something as easy as this.
The question is however:
Can you include shader support in your application without too much hastle?
Do you know shader programming?
EDIT:
You probably don't have a 3D context where you can do stuff like this =/
I was mostly just airing my thoughts.
Manipulating the picture pixel by pixel should be doable in real-time with a single CPU shouldn't it?
If not, look into GPGPU programming and Open CL.
EDIT AGAIN:
If you gave some more details about what the app actually does we might help a bit more? For example, if you're making a web-app none of my tips would make sense.
Thanks for the help everyone. It seems that this can be solved using the ImageAttributes class and simply setting a color remap table.
ColorMap[] maps = new ColorMap[someNum]
// add mappings
imageAttrs.SetRemapTable(maps);
Thanks for the help again, at least I learned something.