How to convert a matlab code to C-code ?
Afficher commentaires plus anciens
Its quite urgent,can anybody tell me how to convert a matlab code to C-code ???
Réponses (4)
Jan
le 14 Juil 2011
2 votes
If it is urgent for you, take the time to explain the problem with all needed details.
The separation of a 3D-RGB array is not complicated in C, if the array has the same format as in Matlab. But is this the case? How did you obtain the pixel values in C? We cannot guess such details...
For an [M x N x 3] RGB array of type UINT8, the first [M x N] bytes are the red channel, then the next [M x N] bytes the green channel, and the last [M x N] bytes are the blue channel.
2 commentaires
keethi2
le 14 Juil 2011
Since jpeg is a compress format it is stored in a more complex way you, reading it is a bit tricky. For the format see here:
I never have done this and I can't help you with posting code. Sorry
Friedrich
le 14 Juil 2011
0 votes
Hi,
Yes, download and maybe buy it if you dont have it. But not all functions are supported for code generation. for a list see here:
10 commentaires
keethi2
le 14 Juil 2011
Friedrich
le 14 Juil 2011
Display an Image in C code isn't a piece of cake. You can't translate this with ML Coder to C code.
Reading the image can be done with basic file i/o command, fopen, fread, fscanf, etc.
keethi2
le 14 Juil 2011
Like I said this isn't easy since C is not made for graphic stuff. Maybe google a bit and you will find some ideas how to do it, e.g.:
keethi2
le 14 Juil 2011
no, you simply decompose your image into his Read Green and Blue parts. if you want to go from rgb to yuv you have to do some multiplication:
keethi2
le 14 Juil 2011
Friedrich
le 14 Juil 2011
It will depend on what image type you are trying to read:
.JPG internal format is totally different from .BMP for example.
C does not have the high-level routines to read an image file - you have to read the file format and process it yourself.
Reading the file is easy:
FILE *input;
char get_char;
input = fopen("myimage.bmp", "rb");
while((get_char=fgetc(input))!= EOF)
{
...
}
fclose(input);
in the ... part add your code to process the data. like stated above this will depend on the file format you are trying to read.
keethi2
le 14 Juil 2011
Friedrich
le 14 Juil 2011
could you explain the full workflow you want to have? do you want to read in the file from hdd or do you get it passed in some format? And especially which format (jpg, bmp) do you working with. Like Jan said. post a full detailed discription of what you are like to do.
Walter Roberson
le 14 Juil 2011
0 votes
Use one of the available software libraries such as libjpeg to read the file. The details of accessing the returned data will then depend upon the format returned by the library.
Catégories
En savoir plus sur Data Type Conversion dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!