matlab图像处理(如何从像素中获得图像的信息)
来源:互联网 发布:日本海军知耻 陆军马鹿 编辑:程序博客网 时间:2024/05/21 02:48
Getting Information about Image Pixel Values and Image Statistics
Getting Image Pixel Values Using impixel
Creating an Intensity Profile of an Image Using improfile
Displaying a Contour Plot of Image Data
Creating an Image Histogram Using imhist
Getting Summary Statistics About an Image
Computing Properties for Image Regions
Getting Image Pixel Values Using impixel
To determine the values of one or more pixels in an image andreturn the values in a variable, use theimpixel function.You can specify the pixels by passing their coordinates as input argumentsor you can select the pixels interactively using a mouse.impixel returnsthe value of specified pixels in a variable in the MATLAB workspace.
Note You can also get pixel value information interactively usingthe Image Tool -- seeGetting Information about the Pixels in an Image.
This example illustrates how to use impixel toget pixel values.
Display an image.
imshow canoe.tif
Call impixel.When called with no input arguments,impixel associatesitself with the image in the current axes.
vals = impixel
Select the points you want to examinein the image by clicking the mouse.impixel placesa star at each point you select.
When you are finished selecting points,pressReturn. impixel returnsthe pixel values in an n-by-3 array, where n isthe number of points you selected. The stars used to indicate selectedpoints disappear from the image.
pixel_values =0.1294 0.1294 0.12940.5176 0 00.7765 0.6118 0.4196
Back to Top
Creating an Intensity Profile of an Image Using improfile
The intensity profile of an image is the set of intensity valuestaken from regularly spaced points along a line segment or multilinepath in an image. For points that do not fall on the center of a pixel,the intensity values are interpolated.
To create anintensity profile, use theimprofile function.This function calculates and plots the intensity values along a linesegment or a multiline path in an image. You define the line segment(or segments) by specifying their coordinates as input arguments.You can define the line segments using a mouse. (By default, improfile usesnearest-neighbor interpolation, but you can specify a different method.For more information, seeSpecifying the Interpolation Method.) improfile worksbest with grayscale and truecolor images.
For a single line segment, improfile plotsthe intensity values in a two-dimensional view. For a multiline path,improfile plotsthe intensity values in a three-dimensional view.
If you call improfile with no arguments,the cursor changes to crosshairs when it is over the image. You canthen specify line segments by clicking the endpoints;improfile drawsa line between each two consecutive points you select. When you finishspecifying the path, pressReturn. improfile displaysthe plot in a new figure.
In this example, you call improfile and specifya single line with the mouse. In this figure, the line is shown inred, and is drawn from top to bottom.
I = fitsread('solarspectra.fts');imshow(I,[]);improfile
improfile displays a plot of the data alongthe line. Notice the peaks and valleys and how they correspond tothe light and dark bands in the image.
Plot Produced by improfile
The example below shows how improfile workswith an RGB image. Use imshow to display the imagein a figure window. Call improfile without anyarguments and trace a line segment in the image interactively. Inthe figure, the black line indicates a line segment drawn from topto bottom. Double-click to end the line segment.
imshow peppers.pngimprofile
RGB Image with Line Segment Drawn with improfile
The improfile function displays a plot ofthe intensity values along the line segment. The plot includes separatelines for the red, green, and blue intensities. In the plot, noticehow low the blue values are at the beginning of the plot where theline traverses the orange pepper.
Plot of Intensity Values Along a Line Segment in an RGB Image
Back to Top
Displaying a Contour Plot of Image Data
You can use the toolbox function imcontour todisplay a contour plot of the data in a grayscale image. A contouris a path in an image along which the image intensity values are equalto a constant. This function is similar to the contour functionin MATLAB, but it automatically sets up the axes so their orientationand aspect ratio match the image.
This example displays a grayscale image of grains of rice anda contour plot of the image data:
Reada grayscale image and display it.
I = imread('rice.png');imshow(I)
Display a contour plot of the grayscaleimage.
figure, imcontour(I,3)
You can use the clabel function to labelthe levels of the contours. See the description ofclabel in the MATLAB Function Referencefor details.
Back to Top
Creating an Image Histogram Using imhist
An image histogram is a chart that showsthe distribution of intensities in an indexed or grayscale image.You can use the information in a histogram to choose an appropriateenhancement operation. For example, if an image histogram shows thatthe range of intensity values is small, you can use an intensity adjustmentfunction to spread the values across a wider range.
To create an image histogram, use the imhist function.This function creates a histogram plot by makingn equallyspaced bins, each representing a range of data values. It then calculatesthe number of pixels within each range.
The following example displays an image of grains of rice anda histogram based on 64 bins. The histogram shows a peak at around100, corresponding to the dark gray background in the image. For informationabout how to modify an image by changing the distribution of its histogram,see Adjusting Intensity Values to a Specified Range.
Read image and display it.
I = imread('rice.png');imshow(I)
Display histogram of image.
figure, imhist(I)
- matlab图像处理(如何从像素中获得图像的信息)
- 定位图像中像素坐标的方法(matlab)
- MATLAB 图像处理函数(第六章)(获取图像矩形像素的运用)
- matlab中图像的处理
- 【matlab 图像处理】MATLAB中图像处理的函数
- 获取图像的像素信息
- 图像处理------基于像素的图像混合
- matlab图像像素运算
- MATLAB中图像处理的函数
- MATLAB中图像处理的函数
- MATLAB中图像处理的函数
- Matlab中关于图像处理的函数
- 图像处理和图像识别中常用的matlab函数
- 图像处理和图像识别中常用的matlab函数
- 图像中获取图像的像素值
- matlab中图像处理的基本函数(1)
- matlab中图像处理的基本函数(2)
- matlab中处理图像如何加快处理速度?
- 百度编辑器的Python后台
- 1031. QQ帐户的申请与登陆(25)
- lcc源代码解析之input.c
- poj 1141 括号匹配
- 【ruby学习笔记】初探ruby
- matlab图像处理(如何从像素中获得图像的信息)
- 设计模式【组合模式】
- poj 3274 哈希
- 奶攀遮扇橇使档歉凳墓玫参椒吨仪
- poj1321 棋盘问题(DFS)
- linux下安装boost (转)
- 转载_大牛讲解信号与系统
- Android 实现ListView的A-Z字母排序和过滤搜索功能,实现汉字转成拼音
- Uva 10815 Andy's First Dictionary