creating 3 3 matrix with image

3 ビュー (過去 30 日間)
Malini Bakthavatchalam
Malini Bakthavatchalam 2020 年 5 月 24 日
Hi, I have an image and I have to convert that image to LMS color space, so the first step I want to know is how do I convert the given image in [3 3] matrix , is there any function?
Thanks
  1 件のコメント
Malini Bakthavatchalam
Malini Bakthavatchalam 2020 年 5 月 24 日
I have used RGB = imread(image.jpg);
M = reshape(RGB,[],3);
and after this i have a [3 3] matrix I have to multiple it with M to get the color transform from RGB to LMS space... But it is showing me error. Thats the reason I want to know the matrix conversion from image.

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

回答 (1 件)

Shravan Kumar Vankaramoni
Shravan Kumar Vankaramoni 2021 年 3 月 24 日
Hi Malini,
I assume that you are trying to convert RGB image to 3x1 and multiply it with 3x3 transformation matrix.
To convert the image to 3x1 , you can use
[R,G,B] = imsplit(image);
Which will extract R,G,B dimensions and then multiply with transformation matrix(3*3) to get the LMS colourspace image. Refer to RGB to HSV conversion example for more information.
The following code demonstrates RGB to LMS conversion
image = imread('corn.tif',2);
% imsplit() gives the image components separately
[R,G,B] = imsplit(image);
%converting to 3x1 matrix to multiply with tranformation matrix
b = [reshape(double(R),415*312,1) reshape(double(G),415*312,1) reshape(double(B),415*312,1)]';
transformation_matrix = [17.8824,43.5161,4.1194;3.4557,27.1554,3.8671;0.0300,0.1843,1.4671];
% output is in the L M S format
output = transformation_matrix * b;
[X,Y] = size(R);
%converting back to original shape
first = reshape(output(1,:),X,Y);
second = reshape(output(2,:),X,Y);
third = reshape(output(3,:),X,Y);
imout(:,:,1) = first ;
imout(:,:,2) = second ;
imout(:,:,3) = third ;
imout = uint8(imout);
imshow(imout);

カテゴリ

Help Center および File ExchangeImage Filtering and Enhancement についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by