RGB to L*a*b color space conversion
7 次查看(过去 30 天)
显示 更早的评论
clc;
clear;
clear all;
fontSize=10;
%original Image
rgbImage = imread('C:\Users\Keerthi Dev\Desktop\tomato_dataset\Tomato_late_blight_water_mold\late300.jpg');%read image
subplot(2, 3, 1);
imshow(rgbImage, []);
title('Original Image', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
rgbImage = imadjust(rgbImage,stretchlim(rgbImage),[]);
rgbImage = imreducehaze(rgbImage);
%subplot(2, 2, 2);
%imshow(rgbImage);
grayImage = rgb2gray(rgbImage);
subplot(2, 3, 2);
imshow(grayImage, []);
title('Grayscale Image', 'FontSize', fontSize);
%freehand code
hFH = imfreehand();
% Create a binary image ("mask") from the ROI object.
binaryImage = hFH.createMask();
xy = hFH.getPosition;
blackMaskedImage = grayImage;
blackMaskedImage(~binaryImage) = 0;
maskedRgbImage = bsxfun(@times,rgbImage,cast(binaryImage, 'like',rgbImage));
subplot(2, 3, 3);
imshow(maskedRgbImage);
title('Binary mask of the region', 'FontSize', fontSize);
%change background as white
%rgbImage = imread('image.png');
%subplot(2, 2, 1);
%imshow(rgbImage);
mask = all(maskedRgbImage == 0, 3);
% Take the largest blob
mask = bwareafilt(mask, 1);
%subplot(2, 3, 4);
%imshow(mask);
maskedRgbImage1 = maskedRgbImage + uint8(255 * repmat(mask, [1, 1, 3]));
subplot(2, 3, 5);
imshow(maskedRgbImage1);
title('complement of the region', 'FontSize', fontSize);
%maskedRgbImage = rgbImage;
%maskedRgbImage = imadjust(maskedRgbImage,stretchlim(maskedRgbImage),[]);
%maskedRgbImage = imreducehaze(maskedRgbImage);
%figure
%imshow(maskedRgbImage);
%lab = rgb2lab(maskedRgbImage);
%figure,imshow(lab);
%cropping the image
m1=min(maskedRgbImage1,[],3);
binaryImage = m1 < 200;
binaryImage = bwareafilt(binaryImage, 1);
[rows,columns]=find(binaryImage);
row1=min(rows);
row2=max(rows);
col1=min(columns);
col2=max(columns);
croppedImage = maskedRgbImage1(row1:row2,col1:col2,:);
subplot(2,3,6);
imshow(croppedImage);
title('cropped image', 'FontSize', fontSize);
Result of this code is,
The next pre-processing step is the colour space conversion. The colour space is converted from a device dependent RGB model into a device independent model. The proposed system uses L*a*b* (L* signifies the lightness, a* and b* are the chromaticity layers) colour space. The background eliminated resized RGB image is converted into L*a*b* first, then, the segmentation module is executed on ‘a*b*’ channel. Using only two channels for colour representation decreases the processing time as well.
So how do I do that? Please help me.
回答(1 个)
Image Analyst
2020-8-22
编辑:Image Analyst
2020-8-22
However just be aware that the lab values you get are just arbitrary "book formula" lab values, and will not be the same lab values you'd get from a spectrophotometer or colorimeter instrument. Hopefully you understand what that means.
You can also use the Color Thresholder on the Apps tab of the tool ribbon.
Oh, and search the "leaf" tag to the right on this page. Click leaf. Leaf analysis seems to be one of the most popular image processing projects, along with fruit, Indian money, and OCR.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modify Image Colors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!