Forum Discussion
Altera_Forum
Honored Contributor
17 years agoTaking image as input
Hello friends.....i am trying to do image processing using DE2 board in verilog hdl and i had written the code...but i got stucked at taking image as input and to load it into the memory on the board...
Altera_Forum
Honored Contributor
17 years ago --- Quote Start --- Try with a .mif file related to a lpm_rom megafunction. In this file you should include the image contents, organized, i.e, by rows. This matlab function takes a matlab vector var and creates a .mif file of depth cells and width bits each one. function miffile(filename,var,width,depth) fh=fopen(strcat(filename,'.mif'),'w+'); fprintf(fh,'WIDTH=%d;\r\n',width); fprintf(fh,'DEPTH=%d;\r\n',depth); fprintf(fh,'ADDRESS_RADIX=DEC;\r\n'); fprintf(fh,'DATA_RADIX=DEC;\r\n'); fprintf(fh,'CONTENT BEGIN\r\n'); for k=1:length(var) fprintf(fh,strcat(num2str(k-1),':',num2str(var(k)),';\n')); end fprintf(fh,'END;\r\n'); fclose(fh); Matlab stores the image as a matrix, you should resize it as a vector. in order to read the ROM include two counters, index_column and index_row. index_rom=index_row*(columns_per_row) + index_column --- Quote End --- In the above matlab code what do you mean by filename in the arguments.....should i need to give image name...if so i gave the filename as avergra2.bmp (function miffile(avergra2,var,width,depth)) can you also explain what is the purpose of index_rom (the last command)