# Convert 256 colours image in a 8 colours image and save pixels in a file

Status
Not open for further replies.

##### Full Member level 2
I need help in converting a 256 colour image in an 8 colour image and the save the bits of this image in a file.This file will the be read using verilog function readmemh.
Here it is what I have so far:
-i have read the original image
Code:
imfile = fullfile('griphon.jpg');
figure('Name','RGB Truecolor Image')
imagesc(original_image)
axis image
zoom(0)
-i think i converted it to 8 colours:
Code:
% % Convert RGB to an indexed image with 8 colors
[IND,map] = rgb2ind(original_image,8);
figure('Name','Indexed image with 8 Colors')
imagesc(IND)
colormap(map)
axis image
zoom(0)

But now i do not know how to read the pixels to a file.
I would be grateful if someone could verify what i have so far and also tell me how to save these pixels.

##### Full Member level 2
I have managed to write the script that is converting the images,but i still can't figure out how to write the pixels value in a file.

##### Full Member level 2
Although no one has responded so far ,I will ask another question hoping someone will finally give an answer.
I have a matrix X that it is written in a file.I want that any value written to be written in this format:
''assign mem = value",where i is the location obtained from line*column and value is the corresponding matrix value.

Status
Not open for further replies.