zoukankan      html  css  js  c++  java
  • 数字图像处理实验(17):PROJECT 06-04,Color Image Segmentation 标签: 图像处理MATLAB 2017-05-27 21:13

    实验报告:

    Objective:
    Color image segmentation is a big issue in image processing. This students need to know the basics of this topic.
    Main requirements:
    Ability of programming with C, C++, or Matlab.
    Instruction manual:
    Download Fig. 6.28(b) and duplicate Example 6.15, but segment instead the darkest regions in the image.

    本实验是彩色图像分割,从彩色图像中分割出特定颜色。这里我选了红色,从下面图片分割红色出来,主要是草莓的部分有较多的红色分量。
    原图像:
    原图像

    实验代码:

    %
    close all;
    clc;
    clear all;
    
    %
    img = imread('Fig6.30(01).jpg');
    figure;
    subplot(2, 2, 1);
    imshow(img);
    title('original image');
    
    %
    img1 = im2double(img);
    R = img1(:, :, 1);
    G = img1(:, :, 2);
    B = img1(:, :, 3);
    
    subplot(2, 3, 4);
    imshow(R);
    title('Red');
    subplot(2, 3, 5);
    imshow(G);
    title('Green');
    subplot(2, 3, 6);
    imshow(B);
    title('Blue');
    
    %
    R1 = R(129:256, 86:170);
    R1_ave = mean(mean(R1(:)));
    [M, N] = size(R1);
    sd = 0.0;
    for i = 1:M
        for j = 1:N
            sd = sd + (R1(i, j) - R1_ave) * (R1(i, j) - R1_ave);
        end
    end
    R1_d = sqrt(sd/(M*N));
    
    R2 = zeros(size(img, 1), size(img, 2));
    index = find((R > R1_ave - 1.25*R1_d) & (R < R1_ave + 1.25*R1_d));
    R2(index) = 1;
    
    subplot(2, 2, 2);
    imshow(R2);
    title('segment red');

    实验结果:
    这里写图片描述

    从颜色分割的结果来看,白色部分主要为草莓的那部分区域,也正好是我们所要区分的红色的区域。

  • 相关阅读:
    Ubuntu下录音机程序的使用
    Bash中的数学计算
    Bash中的数学扩展
    Bash的命令替换
    top的用法
    VirtualBox的快照功能
    格式化输出和printf命令
    read命令读取用户输入
    Bash的作业控制
    Codeforces Round #455 (Div. 2)
  • 原文地址:https://www.cnblogs.com/xuhongbin/p/7134153.html
Copyright © 2011-2022 走看看