精华内容
下载资源
问答
  • matlab中 rgb2gray() 函数 具体实现

    万次阅读 多人点赞 2018-06-03 20:13:46
    简介 rgb2gray是matlab内部一种处理图像的函数,通过消除图像色调和饱和度信息同时保留亮度实现将将RGB图像或彩色图转换为灰度图像,即灰度化处理的功能,调用这个功能的格式是I = rgb2gray(RGB),意思是将真彩色...

                简介

        rgb2gray是matlab内部一种处理图像的函数,通过消除图像色调和饱和度信息同时保留亮度实现将将RGB图像或彩色图转换为灰度图像,即灰度化处理的功能,调用这个功能的格式是I = rgb2gray(RGB),意思是将真彩色图像RGB转换为灰度强度图像I 。

            调用格式

    I = rgb2gray(RGB)
    newmap= rgb2gray(map)

    函数算法

    灰度化处理有多种处理方式:分量法 最大法 平均法 加权平均法
    Matlab 中采用的是对R、G、B分量进行加权平均的算法:
    0.2989R+ 0.5870G + 0.1140B
    (注意,rgb2ntsc函数也使用相同的权重来计算Y分量)

            具体函数

    function imgray=rgbimage2gray(imrgb)
    [m,n,t]=size(imrgb);
    for i=1:m
        for j=1:n
            for k=1:t
                
                imgray(i,j,k)=0.299*imrgb(i,j,1)+0.587*imrgb(i,j,2)+0.11400*imrgb(i,j,3);%加权实现从真彩到灰度的降维转换
               
            end
               
        end
    end

    展开全文
  • matlab rgb2gray的实现

    万次阅读 2018-11-12 12:10:13
    rgb2gray是matlab内部一种处理图像的函数,通过消除图像色调和饱和度信息同时保留亮度实现将将RGB图像或彩色图转换为灰度图像,即灰度化处理的功能,调用这...这里,Matlab的rgb2gray函数采用的是对R、G、B分量进行...

      rgb2gray是matlab内部一种处理图像的函数,通过消除图像色调和饱和度信息同时保留亮度实现将将RGB图像或彩色图转换为灰度图像,即灰度化处理的功能,调用这个功能的格式是I = rgb2gray(RGB),意思是将真彩色图像RGB转换为灰度强度图像I 。   灰度化处理有多种处理方式:分量法 最大法 平均法 加权平均法。这里,Matlab的rgb2gray函数采用的是对R、G、B分量进行加权平均的算法:

    0.2989R+ 0.5870G + 0.1140B

     

    验证程序如下(为了便于观察,实验时应选用一个RGB各分量较为明显的图像):

    clear all;clc;close all;

    img = imread('test3.jpg');

     

    % 提取RGB分量

    img_r = img(:,:,1);

    img_g = img(:,:,2);

    img_b = img(:,:,3);

     

    figure;

    subplot(2,3,1),imshow(img), title('原图');

    subplot(2,3,4),imshow(img_r), title('R分量');

    subplot(2,3,5),imshow(img_g), title('G分量');

    subplot(2,3,6),imshow(img_b), title('B分量');

     

    % 灰度变换,公式:f(x,y)=0.2989R+ 0.5870G + 0.1140B

    img_gray1 = img(:,:,1)*0.2989+ img(:,:,2)*0.5870+ img(:,:,3)*0.1140;

    subplot(2,3,2),imshow(img_gray1), title('由公式变换');

     

     % 灰度变换,rgb2gray()函数

    img_gray2 = rgb2gray(img);

    subplot(2,3,3),imshow(img_gray2), title('rgb2gray变换');

     

    上图可以看出,对于R分量图,由于G、B分量的灰度值均为0,因此G、B区域灰度值为0即为黑色区域,R分量区域灰度值均为255即为白色圆区域;同理可解释G、B分量图。

    展开全文
  • Octave中无法使用rgb2gray()函数

    千次阅读 2016-05-09 19:53:58
    在Octave中加载图像并转成灰度图时,发现rgb2gray()函数不存在,上网搜了一下,stackoverflow上给出了相关解释,如下: The problem is that you didn't load your packages. When you type pkg list you can find ...

    在Octave中加载图像并转成灰度图时,发现rgb2gray()函数不存在,上网搜了一下,stackoverflow上给出了相关解释,如下:

    The problem is that you didn't load your packages. When you type pkg list you can find which ones are loaded by an asterisk in front of their names. Load a package with pkg load image.

    Having to load a packages is that thing that most users find strange but if you compare with other languages, such as Python, Perl, or C++, would you expect them to import, use, or #include every libraries available in the system by default? See Octave's FAQ for more details.


    原来Octave缺省状态下缺少相关包,比如图像处理、信号处理方面的包,需要我们手动安装。


    sourceforge上下载相关包,放在Octave的搜索路径上,在Octave的命令行中执行安装命令:

    pkg install -forge package_name 


    rgb2gray()函数需要安装image包。


    附一下sourceforge上Octave的相关包:

    Packages

    These packages are meant for current versions of Octave. See the unmaintainedsection for information on older versions.

    bim

    Package for solving Diffusion Advection Reaction (DAR) Partial Differential Equations

    detailsdownload

    bsltl

    The BSLTL package is a free collection of OCTAVE/MATLAB routines for working with the biospeckle laser technique

    detailsdownload

    cgi

    Common Gatway Interface for Octave

    detailsdownload

    communications

    Digital Communications, Error Correcting Codes (Channel Code), Source Code functions, Modulation and Galois Fields

    detailsdownload

    control

    Computer-Aided Control System Design (CACSD) Tools for GNU Octave, based on the proven SLICOT Library

    detailsdownload

    data-smoothing

    Algorithms for smoothing noisy data

    detailsdownload

    database

    Interface to SQL databases, currently only postgresql using libpq

    detailsdownload

    dataframe

    Data manipulation toolbox similar to R data

    detailsdownload

    dicom

    Digital communications in medicine (DICOM) file io

    detailsdownload

    divand

    divand performs an n-dimensional variational analysis (interpolation) of arbitrarily located observations

    detailsdownload

    doctest

    The Octave-Forge Doctest package finds specially-formatted blocks of example code within documentation files

    detailsdownload

    econometrics

    Econometrics functions including MLE and GMM based techniques

    detailsdownload

    fem-fenics

    pkg for the resolution of partial differential equations based on fenics

    detailsdownload

    financial

    Monte Carlo simulation, options pricing routines, financial manipulation, plotting functions and additional date manipulation tools

    detailsdownload

    fits

    The Octave-FITS package provides functions for reading, and writing FITS (Flexible Image Transport System) files

    detailsdownload

    fl-core

    The package contains code for basic functions in Fuzzy Logic for Octave

    detailsdownload

    fpl

    Collection of routines to export data produced by Finite Elements or Finite Volume Simulations in formats used by some visualization programs

    detailsdownload

    fuzzy-logic-toolkit

    A mostly MATLAB-compatible fuzzy logic toolkit for Octave

    detailsdownload

    ga

    Genetic optimization code

    detailsdownload

    general

    General tools for Octave

    detailsdownload

    generate_html

    This package provides functions for generating HTML pages that contain the help texts for a set of functions

    detailsdownload

    geometry

    Library for geometric computing extending MatGeom functions

    detailsdownload

    image

    The Octave-forge Image package provides functions for processing images

    detailsdownload

    image-acquisition

    The Octave-forge Image Aquisition package provides functions to capture images from connected devices

    detailsdownload

    instrument-control

    Low level I/O functions for serial, i2c, parallel, tcp, gpib, vxi11 and usbtmc interfaces

    detailsdownload

    interval

    The interval package for real-valued interval arithmetic allows one to evaluate functions over subsets of their domain

    detailsdownload

    io

    Input/Output in external formats.

    detailsdownload

    java

    Provides Java interface with OO-like Java objects manipulation

    detailsdownload

    level-set

    Routines for calculating the time-evolution of the level-set equation and extracting geometric information from the level-set function

    detailsdownload

    linear-algebra

    Additional linear algebra code, including general SVD and matrix functions

    detailsdownload

    lssa

    A package implementing tools to compute spectral decompositions of irregularly-spaced time series

    detailsdownload

    ltfat

    The Large Time/Frequency Analysis Toolbox (LTFAT) is a Matlab/Octave toolbox for working with time-frequency analysis, wavelets and signal processing

    detailsdownload

    mapping

    Simple mapping and GIS .shp and raster file functions

    detailsdownload

    mechanics

    Library with functions useful for numerical computation in classical mechanics and structural analysis

    detailsdownload

    miscellaneous

    Miscellaneous tools that don't fit somewhere else

    detailsdownload

    mpi

    Octave bindings for basic Message Passing Interface (MPI) functions for parallel computing

    detailsdownload

    msh

    Create and manage triangular and tetrahedral meshes for Finite Element or Finite Volume PDE solvers

    detailsdownload

    mvn

    Multivariate normal distribution clustering and utility functions

    detailsdownload

    nan

    A statistics and machine learning toolbox for data with and w/o missing values

    detailsdownload

    ncarray

    Access a single or a collection of NetCDF files as a multi-dimensional array

    detailsdownload

    netcdf

    A MATLAB compatible NetCDF interface for Octave

    detailsdownload

    nurbs

    Collection of routines for the creation, and manipulation of Non-Uniform Rational B-Splines (NURBS), based on the NURBS toolbox by Mark Spink

    detailsdownload

    ocs

    Package for solving DC and transient electrical circuit equations

    detailsdownload

    octcdf

    A NetCDF interface for octave

    detailsdownload

    octclip

    This package allows to do boolean operations with polygons using the Greiner-Hormann algorithm

    detailsdownload

    octproj

    This package allows to call functions of PROJ

    detailsdownload

    odepkg

    A package for solving ordinary differential equations and more

    detailsdownload

    optics

    Functions covering various aspects of optics

    detailsdownload

    optim

    Non-linear optimization toolkit

    detailsdownload

    optiminterp

    An optimal interpolation toolbox for octave

    detailsdownload

    parallel

    Parallel execution package

    detailsdownload

    quaternion

    Quaternion package for GNU Octave, includes a quaternion class with overloaded operators

    detailsdownload

    queueing

    The queueing package provides functions for queueing networks and Markov chains analysis

    detailsdownload

    secs1d

    A Drift-Diffusion simulator for 1d semiconductor devices

    detailsdownload

    secs2d

    A Drift-Diffusion simulator for 2d semiconductor devices

    detailsdownload

    secs3d

    A Drift-Diffusion simulator for 3d semiconductor devices

    detailsdownload

    signal

    Signal processing tools, including filtering, windowing and display functions

    detailsdownload

    sockets

    Socket functions for networking from within octave

    detailsdownload

    sparsersb

    Interface to the librsb package implementing the RSB sparse matrix format

    detailsdownload

    specfun

    Special functions including ellipitic functions, etc

    detailsdownload

    splines

    Additional spline functions

    detailsdownload

    statistics

    Additional statistics functions for Octave

    detailsdownload

    stk

    The STK is a (not so) Small Toolbox for Kriging

    detailsdownload

    strings

    Additional functions for manipulation and analysis of strings

    detailsdownload

    struct

    Additional Structure manipulations functions

    detailsdownload

    symbolic

    The Octave-Forge Symbolic package adds symbolic calculation features to GNU Octave

    detailsdownload

    tisean

    Port of TISEAN 3

    detailsdownload

    tsa

    Stochastic concepts and maximum entropy methods for time series analysis

    detailsdownload

    video

    A wrapper for ffmpeg's libavformat and libavcodec, implementing addframe, avifile, aviinfo and aviread

    detailsdownload

    vrml

    3D graphics using VRML

    detailsdownload

    windows

    Provides COM interface and additional functionality on Windows

    detailsdownload

    zeromq

    ZeroMQ bindings for GNU Octave

    detailsdownload

    Renamed or moved packages

    Some packages have been renamed or merged over time. When thishappens, a dummy transitional package is created -- empty anddependent on its new package. After some time, those are removedas well. The following is a list of such packages:

    • combinatorics -merged into miscellaneous and specfun
    • openmpi_ext - renamed mpi.
    • physicalconstants - merged into miscellaneous.
    • time - merged into financial.

    Unmaintained packages

    The Octave Forge project is a location to develop multiple packages for GNUOctave. With time, some packages become unmaintained, usually because the originalauthor no longer requires it and no one steps up to take its position. Without amaintainer or active user base, and as Octave evolves, we do not know how usablethey are, so we can no longer honestly recommend their use.

    They are still stored and release tarballs can be downloaded from ourFile Release System(same for the very oldmonolithic releases) .However, many of them have accumulated bug fixes and new features in themercurial orSVNrepositories, it simply happens that no maintainer has prepared a release.Because of this, we encourage users to check the development sources, not the releasedtarballs. Furthermore,bug reports for those packagescontinue to be welcome, and anyone wishing to take up the position of maintainer, please contactus through themaintainers mailing list.

    The complete list of unmaintained packages is:

    • actuarial
    • ad
    • ann
    • audio
    • benchmark
    • bioinfo
    • civil-engineering
    • engine
    • fenv
    • gnuplot
    • gsl
    • informationtheory
    • integration
    • irsa
    • missing-functions
    • multicore
    • nlwing2
    • nnet
    • oct2mat
    • octgpr
    • odebvp
    • outliers
    • pdb
    • plot
    • simp
    • special-matrix
    • symband
    • tcl-octave
    • xraylib
    • zenity


    参考:

    [1]:http://octave.sourceforge.net/

    [2]:http://octave.sourceforge.net/packages.php

    展开全文
  • 如图,有没有大佬知道问题出在哪里呀 啊,解决了,有个m文件和函数名字一样。。。。害,删了或者重命名就好了

    如图,有没有大佬知道问题出在哪里呀

     

    啊,解决了,有个m文件和函数名字一样。。。。害,删了或者重命名就好了

    展开全文
  • 出现这种情况是你使用的图像是因为是8位色深度的图片,可以使用qq截图等方式将其截图下来改为24位色深度的图片就可以解决其问题。 参考了网上的网友的说法就解决了该问题的。感谢 ...
  • 出现这种情况是你使用的图像是因为是8位色深度的图片,可以使用qq截图等方式将其截图下来改为24位色深度的图片就可以解决其问题。 参考了网上的网友的说法就解决了该问题的。感谢 ......
  • Rgb2Gray

    2017-08-11 08:34:00
    GPU上运行的函数又称为Kernel,用__global__修饰 调用Kernel函数时,用FunctionCall&...(args1, args2, ...) block_shape与thread shape都是一个三维的结构dim(x,y,z), 其中x为横向,y为纵向。变化最快的维度为x,...
  • OpenCV 4.1,cv::cvtColor函数提示:“CV_RGB2GRAY”: 未声明的标识符。 原因:缺少头文件opencv2/imgproc/types_c.h 解决:直接添加头文件即可。 #include <opencv2/opencv.hpp> #include <opencv2/...
  • 问题:Octave找不到类似在matlab中图像处理相关的函数,例如rgb2gray 解决办法:在使用前加载相应的图像包 在Octave命令行输入如下命令 pkg load image  下面的命令可以用来查看已安装的包 pkg list ...
  • 图像处理:rgb2gray

    千次阅读 2019-06-13 10:04:25
    这个函数比较简单,matlab 网站上给出的大约是这个样子, 0.2989R+ 0.5870G + 0.1140B 注意,如果程序中直接写成浮点乘法,相对比较消耗时间,一般我会写成整数乘法的形式, gray = (R*77 + G*150 + B*29) >&...
  • RGBGray

    千次阅读 2018-03-11 16:09:43
    Matlab里内置了一个函数rgb2gray()实现该功能 也可以用公式实现转化 G=0.30*R+0.59*G+0.11*B rgb_image=imread('Fig0604(a).tif'); %gray_im=zeros(600,600); %% %不用循环的做法 gray_im=rgb_image(:,:,1)*0.3...
  • 1、练习以下函数imread()、imshow()、subplot()、rgb2gray()、imresize() 2、读取lena.bmp图像并显示,将其反色处理后再显示 二、函数分析: 1、imread() 定义:从图形文件读取图像 形式:A = imread...
  • 最近在分析彩色图片灰度化的过程中使用到了一个函数skimage.color中的rgb2gray(),但是与自己所实现的灰度化公式在计算结果上出入较大,因此特意写这篇文章记录一下对比过程. 首先,看一下RGB转Gray的计算公式 : Gray ...
  • 将 RGB 图像转换为灰度图像的函数。 默认行为与 MATLAB 的(IP 工具箱)RGB2GRAY 相同,但 MRGB2GRAY 还具有其他几种转换方案。
  • Matlab中imread和rgb2gray的使用

    千次阅读 热门讨论 2020-05-29 14:36:13
    imread函数是从图形文件读取图像。它的语法为: A = imread(filename) A = imread(filename,fmt) A = imread(___,idx) A = imread(___,Name,Value) [A,map] = imread(___) [A,map,transparency] = imread(___...
  • Matlab图像处理rgb2ind函数

    千次阅读 2020-06-12 16:56:31
    函数将真彩色图像转换为索引图像, 由于RGB图像一个像素占用三个字节, 分别存储R、G、B分量的值,而索引图像一个像素占用一个字节。在将灰度图像转换为索引图像时, 是从3个字节映射到一个字节的关系。 通常有...
  • imread函数读入图像: 只需要将imread的第二个参数置为0即可。 Mat imread(const string& filename, intflags=1 ); 第一个参数是载入图片名,第二个参数是int类型的flags,为载入标识,它指定一个加载图像的...
  • rgb2gray()函数: % 将彩色图像转换成灰度图像 imgray = rgb2gray( imread( path ) );  3、graythresh()函数: % 使用最大类间方差法找到图片的一个合适的阈值。 V1=imread(A); V1=rgb...
  • 【python】 彩图RGB 灰度gray互相转化

    万次阅读 2019-01-23 20:07:40
    RGB到灰度图转换公式:  B' = 0.299 R + 0.587 G + 0.114 B 定义函数 # convert rgb (224,224,3 ) to gray (224,224...def rgb2gray(rgb): return np.dot(rgb[..., :3], [0.299, 0.587, 0.114]) #分别对应通道...
  • 实验室 = rgb2lab(im); f = 0; wlab = reshape(bsxfun(@times,cat(3,1-f,f/2,f/2),lab),[],3); [C,S] = pca(wlab); S = reshape(S,size(lab)); S = S(:,:,1); 灰色 = (S-min(S(:)))./(max(S(:))-min(S(:))); 结尾
  • 文章目录一、概念二、函数的使用 一、概念 rgb_image:表示 RGB 图像 gray_image:表示 RGB 图像 bw:表示 RGB 图像 适用于在 RGB、索引和灰度图像之间进行转换的工具箱函数: ...函数 rgb2gray:...
  • 此功能将 RGB 图像转换为带或不带过滤的灰度图像。此文件已更新以提供具有加载和保存 UI 的良好用户界面。
  • 今天我们更进一步,来看看Emgu CV如何捕捉摄像头并显示视频。 思路很简单,Capture cap = new Capture()来开启一个新...这里说明一下,若使用imshow函数将视频帧显示在窗口里,是不需要多线程的,用户不想得到视频帧时
  • 使用dji manifold获取X3云台相机图像,格式为NV12,简单来说就是存储图像的另外一种格式,opencv3.0以上版本提供了直接转换的函数。#define FRAME_SIZE (1280*720*3/2) /*format NV12*/ #define Width 1280 #define ...
  • 使用Matlab给灰度图像上色的 Gray2RGB 函数,需要额外提供一张配色接近的图片。 该原始算法源于Jeny Rajan , Chandrashekar,但其运行速度过慢,我做了一些Matlab特有的小优化,大大提高了运行速度。
  • 处理RGB和索引图像的函数

    千次阅读 2017-03-30 16:11:07
    其中用到的工具箱函数函数 目的 dither 采用抖动从RGB图像创建索引图像 grayslice 采用阈值处理从灰度图像创建索引图像 gray2ind 从灰度图像创建索引图像 ind2gray ... rgb2gray 从RGB图像创
  • CV_BGR2GRAY COLOR_BGR2GRAY

    千次阅读 2020-04-09 09:29:39
    OpenCV的颜色空间转换函数: C++:voidcvtColor(InputArraysrc, OutputArraydst,...参数dstCn原来一直沿用CV_BGR2GRAY,CV_RGB2GRAY,CV_GRAY2BGR,CV_GRAY2RGB等格式,但最新几个版本的OpenCV已改为COLOR_BGR2GRAY类...
  • 此代码最初的灵感来自 Jeny Rajan 和 Chandrashekar PS 的代码 gray2rgb。该代码经过优化和重写,以更接近地实现 Welsh、Ashikhmin 和 Mueller 的论文“将颜色转换为灰度图像”中描述的内容。 获得与 Rajan 代码...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 572
精华内容 228
关键字:

rgb2gray函数