Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

14-Bit Raw Data Displayed on a TImage??

Posted on 2003-10-27
9
Medium Priority
?
306 Views
Last Modified: 2010-04-05
Hi,

I am writing a program that reads in raw image data from a file and prints it to a TImage box in Delphi.  The Image format is 14-bit grayscale (i.e. 16383 intensity values).  I have tried to code this up using the following procedure image just isnt representative of what it should be like.

procedure TForm1.DrawImageButtonClick(Sender: TObject);
var
   i, j: integer;
   Grayshade, Red, Green, Blue: Byte;
begin
  for j := 0 to 576 do
    begin
       for i:= 0 to 771 do
         begin

             // This routine gets the Red, Green and Blue components and converts them into gray
             Red        := ImArray[i][j];
             Green      := ImArray[i][j] shr 8;
             Blue       := ImArray[i][j] shr 16;
             Grayshade  := Round(0.3 * Red + 0.6 * Green + 0.1 * Blue);

             Image1.Canvas.Pixels[i,j] := RGB(Grayshade,Grayshade,Grayshade);
         end;
     end;
end;


If you could point me in the right direction that would be great.  I am relatively new to Delphi so if I am using totally the wrong technique then I am open to other suggestions.  

Just to re-iterate, the image format is 14-bit grayscale, dont ask me why, probably something to do with the hardware where the data comes from.

Your help is much appreciated.
0
Comment
Question by:engdmorr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
9 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 252 total points
ID: 9634141
14-bit greyscale? Then what are the last two bits used for? Or are the last two bits used as the first two bits of the next pixel? If this is a stream of bits then you have to do a bit more calculations to find the position of a pixel. If it's just 14 bits padded to 16 bits then your code should work.
0
 

Author Comment

by:engdmorr
ID: 9635655
The last two bits arent used for anything.  The program gets its data from a raw image file and I disgard the two LSB's by doing a 'div 4' on the value.  I thought the above should work as well, thats why I coded it :)  But it doesnt.  I was thinking, would creating my own 14-bit pallette in Delphi be an option?  Has anyone attempted creating their own pallette before?
0
 
LVL 34

Assisted Solution

by:Slick812
Slick812 earned 248 total points
ID: 9639377
hello engdmorr, I can not find what you are trying to do with your code? What is this code

Red := ImArray[i][j];
 Green := ImArray[i][j] shr 8;
 Blue  := ImArray[i][j] shr 16;

suppose to do?
as near as I can figure, There are no Red, Green and Blue values in a 14 bit grayscale. . . It might have 16383 intensity values of GREY, no red green and blue, much like the 8 bit greyscale, which has 256 grey values, but no Red, green or blue values. I have not tried to do a 14 bit read, but I do notknow if there would be any padding, but maybe there would be, since reading 14 bit boundries, wound seem to be difficult be difficult, but you might try to read an intensity of grey fron the ImArray[i][j] instead of the Red, green and blue values, and then divide by 64 to get a value between 0 and 255. . . what is the ImArray an Array of? what is it, an array of word (16-bit)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 34

Expert Comment

by:Slick812
ID: 9639450
if ImArray[i][j] is a "WORD" (16-Bit),  and the Unused bits are Not Set, then you might try

Grayshade  := ImArray[i][j] div 64;
Image1.Canvas.Pixels[i,j] := RGB(Grayshade,Grayshade,Grayshade);

0
 
LVL 34

Expert Comment

by:Slick812
ID: 9639517
or just eliminate the high bits

Grayshade  := (ImArray[i][j] and not $C000) div 64;
Image1.Canvas.Pixels[i,j] := RGB(Grayshade,Grayshade,Grayshade);
0
 

Author Comment

by:engdmorr
ID: 9650824
Still nothing seems to work.  Will probably just give up now, have spent far too much time on this one.  Thanks for all the comments though.
0
 
LVL 34

Expert Comment

by:Slick812
ID: 9652929
if the bits are in the upper segment of the of the word value, you might try a shr 8

Grayshade  := ImArray[i][j] shr 8;
Image1.Canvas.Pixels[i,j] := RGB(Grayshade,Grayshade,Grayshade);
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question