1

I have a server serving 12bit image and I can access the image through http, but since it is 12 bit image I am not able to load into System.Drawing.Bitmap(Stream stream).

Image format PNG bit depth 12

Image is here original 12 bit one 12 Bit image

This is how the image should look once you are able to Load.enter image description here

yesraaj
  • 46,370
  • 69
  • 194
  • 251
  • Since this is a non standard format you'll have to discern what format it is and parse the file yourself, I guess. – David Heffernan Apr 09 '13 at 22:23
  • Willing to give it a shot if you can link me to an example image? :) – Simon Whitehead Apr 09 '13 at 22:23
  • You may be stuck performing a BFI (Brute Force & Ignorance) translation. The good news is that it is dead simple to write. – Pieter Geerkens Apr 09 '13 at 22:24
  • Sorry it is PNG Image, but 12 bit depth – yesraaj Apr 09 '13 at 22:25
  • But 12bit doesn't even exist - http://en.wikipedia.org/wiki/Color_depth, can you upload a sample image? This may help: http://stackoverflow.com/questions/3920683/how-to-convert-a-12-bit-image-to-8-bit-in-c-c – Jeremy Thompson Apr 09 '13 at 22:26
  • 1
    I am trying to get hold of a image, it should be same as regular PNG 8 bit but uses 12 bit for dynamic range. – yesraaj Apr 09 '13 at 22:30
  • 2
    Can popular image viewers/editors (like Paint, IrfanView, GIMP, etc) show the image? – Csaba Toth Apr 09 '13 at 22:58
  • @SimonWhitehead Added image and also how it should look. – yesraaj Apr 10 '13 at 00:06
  • @PieterGeerkens Added image and also how it should look once you process – yesraaj Apr 10 '13 at 00:10
  • The image you posted is a 16bpp image. About what you'd expect, considering that PNG doesn't support a 12bpp format. Assuming you actually started with a real 12bpp image then PNG is not the kind of format you'd want to use. Look for formats common in health care, like DICOM. Codecs for them cost money. – Hans Passant Apr 10 '13 at 00:18
  • @HansPassant I cannot change the format of image. I have posted two images one is in 12 bit it is fully dark as it was not able to read and the other one shows how it should look. – yesraaj Apr 10 '13 at 00:21
  • Then your question just doesn't make any sense. You don't actually have a 12bpp image, you've got a 16bpp image that looks like an ink pot fell over. No amount of magic is going to give you a match for the original unless you turn the lights off. – Hans Passant Apr 10 '13 at 00:30
  • @yesraaj: I believe it's also 16bpp. What 12 is the number of unique colors it uses! But if your software serves the web, I just tell you that FF, Chrome and even IrfanView displays the black image. So even if they are wrong too and cannot decode it well, think about if you want to "support" this image. – Csaba Toth Apr 10 '13 at 00:32
  • It is shown as 16 bit in Windows file property but it is a 12 bit image, that i what I was told. – yesraaj Apr 10 '13 at 00:33
  • 1
    @yesraaj Hmmm, this will need a hex editor. – Csaba Toth Apr 10 '13 at 00:41
  • @HansPassant It is good if none of the generic viewers is not able to read the format, we really don't want to work on any other tools. – yesraaj Apr 10 '13 at 00:42
  • @yesraaj So what is the tool/library which generated the wanted jpg image? What can display it correctly? Just before you want to implement something it's good to know. – Csaba Toth Apr 10 '13 at 21:02

1 Answers1

2

You may be able to read the image when using OpenCV library, since it also supports 12bit. You may also prefer to look for an adapter/wrapper, in order to use it in c#, since it is originally a C++ library

also look at those posts:

OpenCV: Working with 12bit gray scale raw data

What is the BMP format for Gray scale Images?

Convert 12-bit Bayer image to 8-bit RGB using OpenCV

hope it helps

Community
  • 1
  • 1
Amegon
  • 629
  • 6
  • 15
  • 1
    `System.Drawing.Bitmap` means .NET land. Although he could craft a solution constructing an interop assembly. – Csaba Toth Apr 09 '13 at 22:59
  • 1
    .Net land does not forbid OpenCV. I already used OpenCV through a wrapper in a VB project and also converted some opencv pictures to .Net land bitmaps, so it is possible. Because of dll declare interop, therefore I said that he should look for a wrapper/adapter – Amegon Apr 09 '13 at 23:06
  • 1
    I say the same: it's possible with an interop. But first he should debug more and be sure. He is talking about accessing the image through http, maybe it's an ASP.NET code on server side, who knows. We don't know if the software is in production, it maybe not as easy to add a 3rd party dll. If the CLR doesn't support the format, it's probably much better to use OpenCV than write some code on his own. There can be funky image dimensions, etc. – Csaba Toth Apr 09 '13 at 23:14
  • I agree, using standard methods to access the pictures, it is more than very unusual if the pictures would be in an unusual format. Thanks for explaining in more detail – Amegon Apr 10 '13 at 00:17
  • I give a +1 because someone -1 or -2 you too, and if that support this image than it's a solution. – Csaba Toth Apr 10 '13 at 00:34