필터 지우기
필터 지우기

How to extract L,a and b from a cell

조회 수: 2 (최근 30일)
Elvin
Elvin 2013년 12월 14일
댓글: Elvin 2013년 12월 18일
I have 6 images and store it in a cell. I then convert it to LAB space. But how do I get the L, a and b channel from the cell? Here's my code:
clear
imgformat = 'LCC%d.jpg';
for k = 1:6
LCC{k} = imread(sprintf(imgformat, k));
cform = makecform('srgb2lab');
lab_Image{k} = applycform(LCC{k},cform);
end
How am I going to get all the L, a and b channel of those 6 images? How should I use the LChannel = lab_Image(:, :, 1); code when working with cell?
Thanks

채택된 답변

Image Analyst
Image Analyst 2013년 12월 14일
No, you made lab_Image a cell , not a regular 3D array . The 3D array is actually INSIDE the cell so you need to pull it out first - at least that is the least confusing and most intuitive way to do it.
theImage = lab_Image{theIndex}; % theIndex can be from 1 to 6
LChannel = theImage(:,:,1);
AChannel = theImage(:,:,2);
BChannel = theImage(:,:,3);
  댓글 수: 15
Elvin
Elvin 2013년 12월 16일
Have you seen my code? Can you help me with? I'm really confused with what I'm doing. Sorry for that, I'm just new to MATLAB, especially to image processing. It's my first time studying this. And I was forced to study this because of our project.
My question is, are my codes on the right track?
By the way, I'll make clear of our project. In our project, we are going to test the nitrogen deficiency of rice plants based on their leaf color. So here's our setup:
1. We have 6 shades of green that will be used as reference.
2. We will get the LAB channels of all those 6 images and store it.
3. We will then take a picture of a rice leaf (with a black background) and this picture will be used as the test image.
4. We will get the LAB channel of the test image.
5. We will solve 6 DeltaE (1 test image to 6 reference images) and see which one will have the lowest value. The result is that, the lowest value of DeltaE means that the color of the leaf is closer to one of the 6 reference images.
I hope you understand our project. Also, can you show me an easy way how to do it? I've been doing this for 3 days and I think it's still wrong. :(
Thank you very much for the help and God bless.
Elvin
Elvin 2013년 12월 18일
Any update with this sir?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2013년 12월 14일
편집: Matt J 2013년 12월 14일
Assuming all 6 images are the same size, you can concatenate
LabData=cat(4,lab_Image{:});
and then just index
LChannel=LabData(:,:,1,:);
  댓글 수: 3
Matt J
Matt J 2013년 12월 14일
편집: Matt J 2013년 12월 14일
Well, it worked then, right? Use imshow or similar image display tool to inspect the image content.
Elvin
Elvin 2013년 12월 14일
Thanks anyway bro, I'll just use this:
clear
imgformat = 'LCC%d.jpg';
for k = 1:6
LCC{k} = imread(sprintf(imgformat, k));
cform = makecform('srgb2lab');
lab_Image{k} = applycform(LCC{k},cform);
LChannel{k} = lab_Image{k}(:, :, 1);
AChannel{k} = lab_Image{k}(:, :, 2);
BChannel{k} = lab_Image{k}(:, :, 3);
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by