Writing into a .ppm file in VHDL

Moderator (Company: Titel) #3350744
Nitish Kv wrote:
> I want to write into a .ppm file using RGB data as inputs.
It looks fairly easy:
http://orion.math.iastate.edu/burkardt/data/ppm/ppm.html
You will need a little bit textio and then you're done.

> Has anybody got any VHDL code for reference?
What about you trying it on your own. And when an actual question occurs 
you will find help here. But no one is intended to do all of your 
homework...
Guest #3350835
I am pretty sure he has a RGB sensor input in real and want's to store 
the data. I wonder if "text.io" is the helper in this case.
Moderator (Company: Titel) #3350902
jen opt wrote:
> I am pretty sure he has a RGB sensor input in real and want's to store
> the data.
I had that thought for the shortest possible time span. But the task to 
do this completely in hardware (=VHDL) sounds totally unrealistic. And 
so my second thought is that it must be for simulation only.

But lets wait for the answer...
OP (Company: Student) #3350947
Thanks all

It is for simulation(for comparison tests).

There is no standard resolution for the image. The RGB data can be of 
any size. It is given as an input. And the input data must be written 
into a .ppm file which can be opened as an image.
Guest #3352522
Me too Lothar but we also had these guys in here who asked for such a 
design being capable o doing this, but it seems as if you were right 
this time :-)
OP (Company: Student) #3389993
Hi
Thank you for your response.
 I tried writing a file with rgb data in hex format. But when written 
the image is wrong . I just get a grayscale image.

When I tried opening a random .ppm image in text format it is not in
human readable format.

I am still trying to find in what format the data is written into the
file. (binary and hex did not work).

Please help.

Thanks in advance

Code:
  ppm_file : process
  file ppm_file : TEXT ;
  variable l_handle : line ;
  variable P6    : string(1 to 2 ) := "P6";
  variable name  : string(1 to 17) := "# ppm image";
  variable size  : string (1 to 7) := "800 480";
  variable space : string (1 to 1) := " ";
  variable scope : string (1 to 3) := "255";
  VARIABLE char : integer:= 0;
  begin

    file_open(ppm_file,"image_ppm",write_mode);

        write(l_handle,P6);
        writeline(ppm_file,l_handle);
        write(l_handle,name);
        writeline(ppm_file,l_handle);
        write(l_handle,size);
        writeline(ppm_file,l_handle);
        write(l_handle,scope);
        writeline(ppm_file,l_handle);

    loop
      wait until(rising_edge(clk));

         write(l_handle, (to_hstr(red))); write(l_handle, space);
         write(l_handle, (to_hstr(green))); write(l_handle, space);
         write(l_handle, (to_hstr(blue)));write(l_handle, space);

         writeline(ppm_file,l_handle);
    end loop ;
    file_close(ppm_file);
  end process ppm_file;
(Company: http://www.nkavvadias.com) #3404093
Hi,

I would suggest having a look to Martin J. Thompson's "image processing 
primitives". He has a good and generic approach for reading and writing 
ASCII PGM images. It should be somewhere on github, google for it.

I have built upon this work, in order to support PBM, PGM and PPM (if i 
recall correctly both binary and ASCII).

Let me know if you are interested in my version, it is on sale.


Best regards
Nikolaos Kavvadias
http://www.nkavvadias.com

Reply

A question of your own? This thread is over 13 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.