- Visual Media Processing Using Matlab Beginner's Guide
- George Siogkas
- 253字
- 2021-08-06 16:38:02
Thresholding color images
Another technique we have already covered, that is changed in the task of color image processing, is image thresholding. Color images must be thresholded in each channel separately using a proper threshold and then the results must be combined together. Let's try to do this using the automated Otsu thresholding technique we presented in Chapter 2, Working with Pixels in Grayscale Images.
First, the color channels should be thresholded one by one. Let's see how, writing a script under the name ColorOtsuThresholding.m
:
img_color = imread('my_image_color.bmp'); % Load image red = im2bw(img_color(:,:,1)); % Threshold red channel green = im2bw(img_color(:,:,2)); % Threshold green channel blue = im2bw(img_color(:,:,3)); % Threshold blue channel bin_image_or = red | green | blue; % Find union using OR bin_image_and = red & green & blue; % Find intersection using AND subplot(1,3,1),imshow(img_color),title('Original Image') subplot(1,3,2),imshow(bin_image_or),title('Binary Union Image') subplot(1,3,3),imshow(bin_image_and),title('Binary Intersection Image')
Running this script gives the following result:

Note that the union of two or more binary images can be acquired using the OR operator, which in MATLAB, is denoted by symbol "|". Applying this operator to two binary images, results in an image that contains ones in those pixels that are equal to one in at least one of the two images. The AND operator denoted by symbol "&" leads to a resulting image that contains ones in those pixels that are equal to one in both images. Depending on the task, one method could be preferable to the other. Let's try to illustrate the difference with an example.
- Istio入門與實戰(zhàn)
- 辦公通信設(shè)備維修
- 電腦軟硬件維修從入門到精通
- SiFive 經(jīng)典RISC-V FE310微控制器原理與實踐
- Blender Quick Start Guide
- 超大流量分布式系統(tǒng)架構(gòu)解決方案:人人都是架構(gòu)師2.0
- Source SDK Game Development Essentials
- 圖解計算機組裝與維護
- Intel FPGA權(quán)威設(shè)計指南:基于Quartus Prime Pro 19集成開發(fā)環(huán)境
- 單片機項目設(shè)計教程
- Istio實戰(zhàn)指南
- Blender for Video Production Quick Start Guide
- FPGA實戰(zhàn)訓(xùn)練精粹
- 計算機組裝、維護與維修項目教程
- UML精粹:標(biāo)準(zhǔn)對象建模語言簡明指南(第3版)