color image processing (3*240960 double)
이전 댓글 표시
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
Image Analyst
2020년 7월 11일
편집: Image Analyst
2020년 7월 11일
I'm not sure of the question. So he reshaped to get a list of RGB values, then multiplied by a 3x3 matrix to get values in the new color space, and then reshaped into an RGB image again. So? And it looks like you did the same thing. Your code worked when I ran it, but you didn't say why what it produced was not the "desired result".
You say you want to know "why 3*240960 double is the way worked for him"? Well an Nx3 times a 3x3 will give another Nx3 matrix which can be converted into an RGB image. Can't you ask him questions about his code?
And it just looks like an image where the dark values are darker than the original. What is the illusion supposed to be?
Malini Bakthavatchalam
2020년 7월 11일
Malini Bakthavatchalam
2020년 7월 12일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Blocked Images에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!