Image Processing in MATLAB Tutorial 2 - Color Thresholding

The Motivated Engineer
The Motivated Engineer
79.1 هزار بار بازدید - 9 سال پیش - Image Processing in MATLAB Tutorial
Image Processing in MATLAB Tutorial 2 - Color Thresholding

This is a tutorial series on the image processing toolbox on MATLAB. It mainly aims at demonstrating the functions in an easy and understandable. To watch other videos in this playlist, visit: Image Processing in MATLAB

In this video, we learn how to filter out various objects based on color. As shown in the video, direct threshold on the color won't give us perfect values. So what we have to do is that apply a set of morphological operations after basic thresholding.

Code:
a = imread('input.jpg');
imshow(a);
red = a(:,:,1); green = a(:,:,2); blue = a(:,:,3);
imshow(red)
imshow(green)
imshow(blue)
d = impixel(a);
out = red (g) 180 & green (g) 150 & green (l) 254 & blue (l) 10;*
*(I've used (g), (l) instead of the greater than and less than symbols as they are not allowed in the description on YouTube videos)

imshow(out)
out2 = imfill(out,'holes');
imshow(out2)
out3 = bwmorph(out2,'erode');
imshow(out3)
imshow(out2)
out3 = bwmorph(out2,'dilate',1);
imshow(out3)
out4 = imfill(out3,'holes');
imshow(out4)
stats = regionprops(out4)
imshow(out4)
doc regionprops

By: Surya Penmetsa
9 سال پیش در تاریخ 1393/12/19 منتشر شده است.
79,108 بـار بازدید شده
... بیشتر