how to convert an image to a matrix of pixels?

9 views (last 30 days)
Hi, I have a project of image processing on the DSP;I use the code composer to program it,and i want to use the matlab to convert the jpeg image(640*480) to 2D-array of pixels which i will need it then in my C code. I search in the web of matlab command or program to convert image but i don't found a precise solution. Can anybody here help me? thank's in advance.
  6 Comments
serina drs
serina drs on 10 Dec 2015
Edited: Image Analyst on 10 Dec 2015
thank you both for your helpful comments.
i have another question:the result of my code which running on CCS is big number of pixels(because i add this line
printf("%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d ,%d",image[(*Y)*640+(*X)].G,image[(*Y-1)*640+(*X+1)].G,image[(*Y-1)*640+(*X-1)].G,image[(*Y+1)*640+(*X-1)].G,image[(*Y+1)*640+(*X+1)].G,image[(*Y-2)*640+(*X+2)].G,image[(*Y-2)*640+(*X-2)].G,image[(*Y+2)*640+(*X-2)].G,image[(*Y+2)*640+(*X+2)].G);
to show the result), i want to show the result image. one of my college advise me to :
  1. create a file.m in matlab
  2. decelerate the array
  3. paste the result lines (line per line)
  4. compilation
but i think it is hard to paste each line alone. do you know a helpful way to convert an array of pixels to an image? i'm sorry for this long comment
Phillip Probst
Phillip Probst on 10 Dec 2015
I'm sorry, but I'm not understanding what you want to do correctly. Just to make everything clear:
1.) You are using two different systems: CCS and MATLAB
2.) You want to display the result of your CCS code as an image
3.) To do that, you want to copy the result of your CCS code into MATLAB, to then concatinate the matrcies of your CCS code into a single Matrix
4.) Copy that Matrix and paste that back to CCS
Is that, what you want to do?

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 10 Dec 2015
LOTS of stuff wrong with that code.
It's advisable not to have gigantic chunks of code in functions like fprintf(). Split it up into smaller parts so you can check each. At least onto separate lines. You have virtually a whole program in the argument list of printf()!
There is no function printf() - perhaps you means sprintf() or fprintf() instead.
Things like *X by themselves will cause an error.
You need to use single quotes in MATLAB to define a string, not double quotes.
Don't use image as the name of your variable because that is the name of a built-in function.
What your college adviser told you does not make sense, or you did not convey it correctly. What does "decelerate the array" mean??? And I don't know what each of the 4 steps is supposed to accomplish. It just looks like a random set of tasks. Why do you need to compile this? Are you going to deploy it as a standalone executable or a libary file? Do you have the MATLAB Compiler? Since he seems to think he knows how to solver your problem (and we don't), can you sit down shoulder to shoulder with him until you have this all worked out?
  16 Comments
Mohammad Alwardat
Mohammad Alwardat on 22 Mar 2020
Hi Walter,
I'm new user in mathWorks, so I don't know what is the private consultant.
Image Analyst, excuse me because i asked for your email.
Walter Roberson
Walter Roberson on 22 Mar 2020
A private consultant is someone who is available to be hired to give advice or do work, with the discussions treated as mostly confidential and with the person doing the hiring typically ending up owing the rights to the results ("Work for hire" in copyright terms). All of the benefits of the work go to the person or organization doing the hiring.
Image Analyst is not available for hire.
This particular resource, MATLAB Answers, offers volunteers (no cost), but only for public questions with public responses. The benefits of the work go to whomever bothers to read it, rather than individual gain.

Sign in to comment.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!