After obtaining the pixel values of an image..how to store those pixel values in an array?

6 Ansichten (letzte 30 Tage)
After obtaining the pixel values of an image..how to store those pixel values in an array?
  4 Kommentare
Kamali M
Kamali M am 18 Dez. 2018
If this isnt correct please say that method also along with how to load them in an array?
thanks in advance.
Guillaume
Guillaume am 18 Dez. 2018
Kamali, you have to explain better what it is you want to do. As commented you already have the pixels in an array. It's the my_image array

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

madhan ravi
madhan ravi am 18 Dez. 2018
pixel = cell(1,rows);
ctr = 1;
for R=1:rows
for C=1:columns
pixel{ctr}=my_image(R,C);
disp (R)
end
ctr = ctr+1;
end
celldisp(pixel)
[pixel{:}] % double array
  6 Kommentare
Kamali M
Kamali M am 18 Dez. 2018
ACTUALLY my input is a 256X320 but i get only a single row with 256 elements in it.
my_image =imread('football.jpg');
my_image=rgb2gray(my_image);
[rows,columns,depth]=size(my_image);
pixel = cell(1,rows);
ctr = 1;
for R=1:rows
for C=1:columns
pixel{ctr}=my_image(R,C);
end
ctr = ctr+1;
end
celldisp(pixel)
disp ([pixel{:}]); % double array
what are the necessary changes in it?
thanks in advance.
madhan ravi
madhan ravi am 18 Dez. 2018
Bearbeitet: madhan ravi am 18 Dez. 2018
@kamali see sir Walter's answer this is not the correct approach as mentioned by the peers.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

Walter Roberson
Walter Roberson am 18 Dez. 2018
The pixel values are already stored in my_image and do not need to be stored again .

Kamali M
Kamali M am 18 Dez. 2018
@madhan sir, please tell me what should i change i dont get it..
thank u sir.
  1 Kommentar
Walter Roberson
Walter Roberson am 18 Dez. 2018
What data type do you need as output? What array size do you need as output? What difference do you intend between "pixel values" that you want stored, compared to what is already in my_array ?

Melden Sie sich an, um zu kommentieren.


Saipraveen
Saipraveen am 30 Sep. 2019
For the information of other users, In this file exchange - https://www.mathworks.com/matlabcentral/fileexchange/72535-image-to-c-c-array-converter, I have written a script to generate an array from an image. I convert the input image to monochrome and store the pixel values in hex format in a different file. It could be modified to suit your needs.
Hope that helps.

Kategorien

Mehr zu Images finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by