Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

converting binary image (8 bits) into Decimal image?

Status
Not open for further replies.

wady1

Newbie level 3
Joined
Aug 13, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,299
How to convert a binary image (8 bits) into decimal image? Would it be bin2dec() is the function to be used? Any example please?
Thank you in advance for your help.
 

is the software matlab?

- - - Updated - - -

is the software matlab?

Yes. But open to use C or C++ if needed, but matlab is what I am using now.
Thank you.
 

How to convert a binary image (8 bits) into decimal image? Would it be bin2dec() is the function to be used? Any example please?
Thank you in advance for your help.
HI THERE
It sounds difficult.There are many image converter which supports to convert image effecively.Maybe you can search it.If there is any powerful one.i 'd also like to have a try.
 

There's a number of ways to do that based on the coder's preference.

Pseudo-codish, take with a grain of salt. I only just got out of bed.
Code:
// This is just a simple converter that takes a binary string and converts it to a char array
#include <string.h>
#include <math.h>

int i = 0;
int length = strlen(BINARYINPUT) / 8; // I have no clue how your original data is saved.
unsigned char output[length];
unsigned char out = 0x00; // It looks trashy to me if a loop declares a value every iteration
do {
  out = bin2dec(BINARYINPUT.substr(i*8,i*8+8));  // 8 chars per hex value, so pos of the substring is i*8, length is i*8+8
  output[i] = out;
  i++;
} while (i < length);

As to saving it as a .BMP file, I dunno, because I have no idea what format your original data is in. There are probably more than Microsoft is willing to list. If you know your pixel format and this binary stream is just pixels, i.e. no header information, then you can save it as a .RAW and use FFMPEG or some image processing tool to convert it to .BMP afterwards.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top