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 jpeg file to ceo file

Status
Not open for further replies.
Do you know how to convert any given binary file to a .coe file? Excellent, now you can convert your .jpg to a .coe file, because a jpg or gif or whatever is just binary data like any other file.

What, you mean you don't know how to convert a binary to .coe? Google not working today? No worries. https://sourceforge.net/projects/bin2coe/files/

If you're a windoze monkey ... win32 binary included. If you're a unix monkey ... comment out the #include <conio.h> on line 2 of bin2coe.c and then compile. You need to do that because the bin2coe author is a bit silly.

Personally I just use a perl script I made eons ago. Or matlab script. or any other rather trivial thingy that does the job of the day.

Hell, you can probably write some verilog to read binary file and spit out a .coe. But that's left as exercise for the reader. :p

Anyways, use that bin2coe.exe thingy and you should do just fine.

Just google on something like "binary to .coe file" to find other relevant material...
 

Hi

my doubt is "how to generate .coe file from jpeg/bmp."
is it directly come by giving image file to rom/ram using xilinx_ip_core...
or by using matlab ..
am read the .coe file link .. but i didn't understand it..

You generate the ROM in using IP generator (for xilinx) and hence you put you file in that ROM since ROM data cannot be changed (by conventional definition) at run time.

As I told you in earlier email. You should have some data (in integer format) which you can write in .ceo format.
The format of .ceo file is given above as well. also the code I gave you in that post will generate the format, you just have to repoen that text file and save-as .ceo.
One more thing I mentioned you have to do is to read your file where you have saved you JPEG image. Let me clear this...(I would ask mrflibble to correct if I am wrong since I am in learning phase I guess)

1. Finalize Image
2. Image taken as input to Matlab and generate some respective integers, that denote the the pixel.
3. Save these numbers into .txt format using matlab (hint use commands like dlmwrite etc...try help in MATLAb for other similar commands for dlmwrite which suits you better). You can have a matrix for the image which you can break down into Vectors, then save individual files for, lets say each coloum...Do this for X- coloumns and you will have x- files having Y- row-element in each (if you consider your image as X*Y matrix)
4. Read this .txt file in the following program in this link
Note that you need to do little learning of C++ at the same time you are doing this.
5. Re-open that .txt file that is generated and save it as the .ceo file.


This may be irrevelant but usually ROMs are not much bigger length and you cannot save whole image in the ROM.
And you cannot change element at run-time, just it can use for comparison reasons..

Hope this helps.
 

@syedshan: Yeah, that should work as well. Use matlab to generate a comma seperated file (with the dlmwrite) and then use another utility to take care of the rest.

Although I usually just use fprintf in matlab to directly write the file I need. But your method should work too.


And since we probably should not be assuming ANYTHING ... having the bits of a .jpg image inside your fpga still is not an image that you can easily display using the usual fpga resources. Case in point, you need something that decodes the jpg into pixely bits.

Right, checked previous posts in thread. The OP also has the following immensely informative quote that explains all the system requirements: "nexys 2 VGA contoller"

So I suppose he want to display the jpg contents on a vga display... In which case see previous statements about decoding. Easy solution is to do the conversion on the PC. convert jpg to bitmap. What is a bitmap? It's a thingy every self respecting digital design person knows how to google. What do I use to convert jpg to bitmap? You use ImageMagick. ImageMagick is awesome. How do I convert that bitmap to .coe? Matlab, any old script, or that coe2bin util I already put a link to in earlier posts.

Did I leave out any other pre-emptable questions? *checks* Nope, can't think of any. Well, that answers everything then. Now you can succesfully convert that jpg into a bitmap into a .coe file that you can include in your .bit file so that it initializes your BRAMs.
 

@syedshan: Yeah, that should work as well. Use matlab to generate a comma seperated file (with the dlmwrite) and then use another utility to take care of the rest.

Although I usually just use fprintf in matlab to directly write the file I need. But your method should work too.

actually just I wrote that comment I thought I am being stupid when one can use MATLAB why use C++, an extra step but I did feel quite lazy coming back and edit... :smile:


having the bits of a .jpg image inside your fpga still is not an image that you can easily display using the usual fpga resources. Case in point, you need something that decodes the jpg into pixely bits.

Actually I have not directly used jpg thingy for FPGA, it is just fusion of my experience over JPEG with Matlab, and FPGA experience which let me think this way that the pixel in matlab can be well taken as pixel inside FPGA.
Thanks for informing me.

I hope the guy who needed this might also get some idea with this discussion now :)
 

actually just I wrote that comment I thought I am being stupid when one can use MATLAB why use C++, an extra step but I did feel quite lazy coming back and edit... :smile:

You lazy you... ;) But I've done the same in the past. If you just happen to have an external tool that does job XYZ already, then you just use that if it means less typing. Even if the overall solution is less elegant, for a one time use solution, who cares. XD As long as there is no such issue as "has to be understood by coworkers" or *gasp* maintainability...


Actually I have not directly used jpg thingy for FPGA, it is just fusion of my experience over JPEG with Matlab, and FPGA experience which let me think this way that the pixel in matlab can be well taken as pixel inside FPGA.
Thanks for informing me.

I hope the guy who needed this might also get some idea with this discussion now :)

Heh, the part about "jpg thingies in fpga" was mainly meant for the OP. :) Given the jpg + vga on nexys2 combo I /guess/ he wants to have a bitmap (as opposed to real jpeg file) inside of his fpga. But only he will know for sure what he wants, it's his project.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top