transfer image pixel values into array for complete image
  • array(,1)=R value
  • array(,2)=G value
  • array(,3)=B value
  • array(,4)=x position
  • array(,5)= y position

1 件のコメント

David Young
David Young 2014 年 2 月 20 日
The question does not make sense. array(,1) is not valid syntax - there needs to be something in front of the comma. Also, what are you transferring the values from?

サインインしてコメントする。

 採用された回答

Image Analyst
Image Analyst 2014 年 2 月 20 日
編集済み: Image Analyst 2014 年 2 月 20 日

0 投票

Try this:
for k = 1 : length(RValues)
array(k, 1) = RValues(k);
array(k, 2) = GValues(k);
array(k, 3) = BValues(k);
array(k, 4) = XValues(k);
array(k, 5) = YValues(k);
end
OR
% For a complete image
k = 1;
[rows, columns, numberOfColorChannels) = size(rgbImage);
if numberOfColorChannels == 3
for col = 1 : columns
for row = 1 : rows
array(k, 1) = rgbImage(row, col, 1);
array(k, 2) = rgbImage(row, col, 2);
array(k, 3) = rgbImage(row, col, 3);
array(k, 4) = col;
array(k, 5) = row;
k = k + 1;
end
end
end
I don't know why you'd ever want this unless maybe you were exporting to some kind of modeling/cadcae program.

2 件のコメント

Image Analyst
Image Analyst 2014 年 2 月 20 日
sonam's "Answer" moved here, since it was not an answer.
1Start
2.img = input plain image.
3 rows, cols = size of img.
4 create array of (rows*cols , 5)
5 transfer img pixel values into array for complete image
array(,1)=R value
array(,2)=G value
array(,3)=B value
array(,4)=x position
array(,5)= y position
6 sort this array
7 img = form an image using this array
8 Invoke ImageEncryption(img, rows, cols)
9 End
Image Analyst
Image Analyst 2014 年 2 月 20 日
I did 1-5 for you. To sort you just call the sort() function but I don't know what column you are sorting on. And 7 is unnecessary since you already have the image - you needed it to do steps 2-5. Only you know what you need to do for step 8.

サインインしてコメントする。

その他の回答 (1 件)

Adam
Adam 2014 年 2 月 20 日

0 投票

If you mean array(:,1) = R value, then:
if true
myImage = imread('myFile.img');
array(:,1) = reshape(myImage(:,:,1),[],1); %red
array(:,2) = reshape(myImage(:,:,2),[],1); %green
array(:,3) = reshape(myImage(:,:,3),[],1); %blue
[array(:,4),array(:,5)] = ind2sub(size(myImage(:,:,1)),1:numel(myImage(:,:,1)));
end

2 件のコメント

sonam s
sonam s 2014 年 2 月 20 日
THANKS FOR YOUR HELP
I HAVE GIVEN THE ALGORITHM BELOW
PLEASE HELP ME HOW TO IMPLEMENT THIS
sonam s
sonam s 2014 年 2 月 20 日
THE BELOW ALGORITHM IS FOR PIXEL PERMUTATION

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by