zoukankan      html  css  js  c++  java
  • 7灰度图像反转 及 彩色图像反转

    灰度图像反转:

    灰度图的灰度值范围一般从0到255,白色为255,黑色为0,故黑白图片也称灰度图像。灰度反转是指对图像灰度范围进行线性或非线性取反,产生一幅与输入图像灰度相反的图像。

    假设一点的灰度值为f(x,y),那么反转后就是255-f(x,y)。

    1、Matlab实现

        使用matlab验证灰度反转。

    %--------------------------------------------------------------------------
    %                       灰度图像反转
    %--------------------------------------------------------------------------
    clc;
    clear all;
    RGB = imread('G:	estAC6102_UART_TFT50_IMG1image.bmp');  %读取图像
    
    gray = rgb2gray(RGB);       %灰度图
    
    inve1 = imcomplement(gray); %函数法图像反转
    inve2 = 255 - gray;         %公式法图像反转
    
    subplot(3,1,1);imshow(gray); title('灰度图像');
    subplot(3,1,2);imshow(inve1);title('函数法图像反转');
    subplot(3,1,3);imshow(inve2);title('公式法图像反转');
    View Code

    代码分别从函数法和公式法,实现了灰度图像的反转。这个灰度图像是从上一次实验提取Y分量得到的。

    2、fpga实现

     

    这里就是将上次Y2直接输出灰度图像的,这里使用公式法将灰度图像反转再输出。结果与matlab一样。


    彩色图像反转:

    1、matlab实现:

    %--------------------------------------------------------------------------
    %                       彩色图像反转
    %--------------------------------------------------------------------------
    clc;
    clear all;
    RGB = imread('G:	est1image.bmp');  %读取图像
    
    inve1 = imcomplement(RGB);  %函数法图像反转
    
    inve2 =  255 - RGB;         %公式法图像反转
    
    subplot(3,1,1);imshow(RGB);  title('原图');
    subplot(3,1,2);imshow(inve1);title('函数法图像反转');
    subplot(3,1,3);imshow(inve2);title('公式法图像反转');
    View Code

    matlab验证结果:

    2、fpga实现:

    由此可见,fpga实现的效果与matlab实现的效果一致。

  • 相关阅读:
    <modules>
    如何禁用Visual Studio 2013的Browser Link功能
    Visual Studio 2013 Web开发、新增功能:“Browser Link”
    MVC中的AppendTrailingSlash以及LowercaseUrls
    js如何关闭当前页,而不弹出提示框
    border-radius实例1
    border-radius讲解2
    border-radius讲解1
    Android服务Service具体解释(作用,生命周期,AIDL)系列文章-为什么须要服务呢?
    最小生成树-Prim算法和Kruskal算法
  • 原文地址:https://www.cnblogs.com/FPGAer/p/14088367.html
Copyright © 2011-2022 走看看