color image processing (3*240960 double)

2 visualizaciones (últimos 30 días)
Malini Bakthavatchalam
Malini Bakthavatchalam el 11 de Jul. de 2020
Comentada: Malini Bakthavatchalam el 12 de Jul. de 2020
Hi, I have doubt, I am attaching code that my senior worked on to create illusion in gray levels. Now I am trying to make that work in color iimages. So, the one thing I noticed while debugging his code is 3*240960 double. He used only 3*240960 double form to find median from his axis and did the rectification required to create illusion only in this 3*240960 double. After doing all that he finally inversed the 3*240960 with the matrix to create a displayable RGB image. But why is that done like that? I was confused with his codes... for a long time. Because I did in my way to convert the image in desired color space and i was working on the RGB image. Which never gave my desired resullt. So I want to know why 3*240960 double is the way worked for him?
Please kindly help.
The below code is my code, that I did with the help of matlab answers section. The attached code is his code.
RGB = imread('originalimg.png');
MyImrgb = reshape(im2double(RGB), [],3);
Imrgb = MyImrgb.^2.2; %gamma correction
[x, y, z] = size(Imrgb);
%% transform my picture in a DKL color space
% Define a DKL2RGB mat based on the classic calibration technic
% this P matrix defines DKL in RGB color space
%ld % rg %yv
ldrgyv2rgbMat = [1.0000 1.0000 0.236748566577269 %R
1.0000 -0.299338211934457 -0.235643322285071 %G
1.0000 0.0137437185685517 1]; % B
MyImrgbCol = reshape(Imrgb * ldrgyv2rgbMat, size(RGB));
MyImldrgyvCol = reshape(reshape(MyImrgbCol, [],3) *inv(ldrgyv2rgbMat),size(MyImrgbCol));
figure(1),imshow(MyImldrgyvCol)
figure (2);
plot3(MyImldrgyvCol(2,1:25:end),MyImldrgyvCol(3,1:25:end),MyImldrgyvCol(1,1:25:end),'r+'); hold on; % displaying the image in the 3 axis where the z axis is kept constant value displaced only on x and y axis
plot3([0 0], [-1 1], [0 0], 'k-','LineWidth', 2);
plot3([-1 1], [0 0], [0 0], 'k-','LineWidth', 2);
plot3([0 0], [0 0], [-1 1], 'k-','LineWidth', 2);
xlabel('LM'); ylabel('S'); zlabel('LD');
axis([-1 1 -1 1 -1 1])
vecx = -1 : 0.50 : 1; vecy = -1 : 0.50 : 1; vecz = -1 : 0.50 : 1;
grid on;
set(gca, ...
'XTick' , vecx , ...
'YTick' , vecy , ...
'ZTick' , vecz );
LMaxes1 = (MyImldrgyvCol(2,:));
MedLM = median(LMaxes1);
figure(3),imhist(LMaxes1)
figure(4),imhist(MyImldrgyvCol(2,:,:))
Thanks
  3 comentarios
Malini Bakthavatchalam
Malini Bakthavatchalam el 11 de Jul. de 2020
Nope, he is not in the lab anymore, all I have is only the previous works...
My question is When i am trying to look at the median value for particular axis say x axis i have to use this function like . But when we run his code LMaxes1 = median(MyImldrgyvCol(2,:)); my MyImldrgyvCol has the value 502*480*3. But when I run his code ... he works with MyImldrgyvCol which is a 3*240960. so after doing all his works in (3*240960) form, only at the end he is transfering to RGB image. but I am not able to do the same way. Also what is the meaning of
RGB = imread('originalimg.png');
MyImrgb = reshape(im2double(RGB), [],3);
Imrgb = MyImrgb.^2.2; %gamma correction
[x, y, z] = size(Imrgb);
%% transform my picture in a DKL color space
% Define a DKL2RGB mat based on the classic calibration technic
% this P matrix defines DKL in RGB color space
%ld % rg %yv
ldrgyv2rgbMat = [1.0000 1.0000 0.236748566577269 %R
1.0000 -0.299338211934457 -0.235643322285071 %G
1.0000 0.0137437185685517 1]; % B
%MyImrgbCol = reshape(Imrgb * ldrgyv2rgbMat, size(RGB));
%MyImldrgyvCol = reshape(reshape(MyImrgbCol, [],3) *inv(ldrgyv2rgbMat),size(MyImrgbCol));
MyImrgbCol = reshape(MyImrgb, [x*y, z]);
% define each RGB pixe lin DKL (inverse matrix Q or P with \)
MyImldrgyvCol = ldrgyv2rgbMat\(MyImrgbCol'*2 - 1);
figure
plot3(MyImldrgyvCol(2,1:25:end),MyImldrgyvCol(3,1:25:end),MyImldrgyvCol(1,1:25:end),'r+'); hold on; % displaying the image in the 3 axis where the z axis is kept constant value displaced only on x and y axis
plot3([0 0], [-1 1], [0 0], 'k-','LineWidth', 2);
plot3([-1 1], [0 0], [0 0], 'k-','LineWidth', 2);
plot3([0 0], [0 0], [-1 1], 'k-','LineWidth', 2);
xlabel('LM'); ylabel('S'); zlabel('LD');
axis([-1 1 -1 1 -1 1])
vecx = -1 : 0.50 : 1; vecy = -1 : 0.50 : 1; vecz = -1 : 0.50 : 1;
grid on;
set(gca, ...
'XTick' , vecx , ...
'YTick' , vecy , ...
'ZTick' , vecz );
LMaxes1 = (MyImldrgyvCol(2,:));
MedLM = median(LMaxes1);
figure(3),imhist(LMaxes1)
figure(4),imhist(MyImldrgyvCol(2,:,:))
DKL = reshape(MyImldrgyvCol, [x,y,z])
imshow(DKL)
I get this error
Error using \
Matrix dimensions must agree.
Error in trycolordkl (line 19)
MyImldrgyvCol = ldrgyv2rgbMat\(MyImrgbCol'*2 - 1);
Malini Bakthavatchalam
Malini Bakthavatchalam el 12 de Jul. de 2020
@Image Analyst , sir I am using the same code then why am I getting the same error ? could you explain me please.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Read, Write, and Modify Image en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by