Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

12bit to 8bit conversion


Is it more difficult than it sounds?  Instead of sending a single 8 bit value, first send the 4 usb padded with zeroes, then send the 8 lsb.  On the other end, put them together as a 16 bit value, which is how LV is going to use them.
Thanx for the idea bruce but i have tried handling a 16 bit image before.I suppose lv doesnt support 16bit image still.I will try your suggestion and get back.Thanx again
0 Kudos
Message 11 of 24
(6,142 Views)

Downshift:

          by applying downshift, you can convert your 12 bits image to 16 bits image and I'm confident you can deal with it from that point.

 

Bit Plane Slicing:

          which by you may eliminate the lower bit planes (planes 0,1,2,3) and keeping the remaining 8 bit planes (plane 4,5,6,7,8,9,10,11). The lower bit planes contain finer details, so your loss won't be drastic.

 

         Downshift methd is already available in NI IMAQ. for the second resolution, you may resort to perform pixel by pixel operation, extracting pixel value, trim the mentioned lower planes and construct the new image.


Thanx a lot for the suggestion.I will defenitely try downshift.Bit plane slicing is what i think i am doing indirectly.Will get back to you once i try your valuable suggestions

0 Kudos
Message 12 of 24
(6,144 Views)
I'm all your muks 🙂
Waleed El-Badry MSc.,MCPD, ISTQB Certified Tester
Assistant Lecturer
Mechatronics Department
Faculty of Engineering
Misr University for Science & Technology



View Waleed El-Badry's profile on LinkedIn

Message 13 of 24
(6,132 Views)

Well still i have not done with this. Now Giving you a clear picture of situation. From the reverse

 

  • I need to map a 1.5 mega pixel image.
  • Before this i ignored the lsb 4 bits from ccd signal processor and receving the bits via my usb controller.Sp got a 8 bit low resolution image.
  • Even now my usb controller can receive only 8 bits so i am trying to transmit the 12 bit data like this

 

245

204

246

 

So I will recive 2250000 bits of data in the format mentioned above.

  • Now I think lv doesnt support 12 bit grayscale values so i need to convert this to 16 bit gray scale image.Please see the image below.

 

 

Waleed,Mike and bruce any insight will be of grt help to me.

 

 

 

 

 

 

Message Edited by muks on 08-27-2008 10:27 AM
0 Kudos
Message 14 of 24
(6,116 Views)

I guess I can repeat my answer if that helps.

 

It looks like you are packing two 12 bit values into three 8 bit values.  You need to write an algorithm that takes three 8 bit values at a time and converts them back to two 12 bit values, then adds four zeroes to get a 16 bit values.  It will be kind of messy, but shouldn't be too difficult.

 

I still think the easier method would be to have your device send the upper 8 bits of your twelve bit value, then send the lower 4 bits with 4 zeroes appended.  Combining the two 8 bit values into a 16 bit value is a piece of cake on the PC side.  The only downside is that sending all those zeroes will increase the amount of data transmitted to 3,000,000 bytes.  Unless this is too much data to transmit, I would think this method would be much easier.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 15 of 24
(6,099 Views)

I still think the easier method would be to have your device send the upper 8 bits of your twelve bit value, then send the lower 4 bits with 4 zeroes appended.  Combining the two 8 bit values into a 16 bit value is a piece of cake on the PC side.  The only downside is that sending all those zeroes will increase the amount of data transmitted to 3,000,000 bytes.  Unless this is too much data to transmit, I would think this method would be much easier.

 

Wow that is exactly what i did. But the problem is looping.I need to run a for loop for 3,000,000 times.That is time consuming.I will post the screen shot or my vi in a while.

 

Thanx bruce

0 Kudos
Message 16 of 24
(6,092 Views)
It is taking more than 10 minutes.Please help
0 Kudos
Message 17 of 24
(6,081 Views)

You are doing it the hard way.  Try these steps:

 

Read an array of 3,000,000 U8 values from the comport.

 

Use Decimate 1D array to split the array into the high and low bytes.

 

Use Join Numbers to combine the two U8 arrays into a single U16 array.

 

Reshape the array to a 2D array for ArrayToImage.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 18 of 24
(6,076 Views)
You did a tremendous and marveolus work muks. I 'm wondering about your persistance towards reading all 12 bits and not just having the higher 8 bits. did the image got distorted?
Waleed El-Badry MSc.,MCPD, ISTQB Certified Tester
Assistant Lecturer
Mechatronics Department
Faculty of Engineering
Misr University for Science & Technology



View Waleed El-Badry's profile on LinkedIn

Message 19 of 24
(6,069 Views)

You are doing it the hard way.  Try these steps:

 

Read an array of 3,000,000 U8 values from the comport.

 

Use Decimate 1D array to split the array into the high and low bytes.

 

Use Join Numbers to combine the two U8 arrays into a single U16 array.

 

Reshape the array to a 2D array for ArrayToImage.


 

I tried that first.But i didnt get the desired output.I need to convert the U8 values to binary then need to join them and then convert it back to decimal value.That way i would have converted the U8 to U16.

 Any idea avoiding the loop would be of grt help.

0 Kudos
Message 20 of 24
(6,058 Views)