讲解:ImageSharp、R、RR|Matlab

Working with imagesImage classAn Image class contained in Image.cs has been provided on Blackboard. It is highlyrecommended that you download and use this class in your project, as it encapsulates a lot ofconvenient functionality for working with images. The Image class requires theSixLabors.ImageSharp 3rd party library to be installed in your project.Start by adding the Image.cs file into a new Console project (.NET core). You should familiariseyourself with this class and the public members it exposes, because you will likely use them inyour solution!Working with RGBA values and pixel intensitiesRGBA values: RGBA stands for red, green, blue, alpha. Every pixel in our images has a RGBAvalue. The alpha channel represents the the transparency of pixels (an alpha value of 0 indicatescomplete transparency, and an alpha value of 255 indicates no transparency). In this assignment,RGBA values are stored using the Rgba32 type. Each component is represented by a byte (an 8-bit integer ranging from 0 to 255). For more information on the Rgba type, see the officialSixLabors documentation page. In our Image class, Rgba32 values at specific pixels can beretrieved using square-bracket indexing (e.g. image[x, y].R ). The overall intensity of an RGBApixel can be retrieved using the image.GetGreyIntensity(...) method, which provides the averageintensity of the RGB channels (eqImageSharp作业代做、R编程语言作业调试、R课程设计作业代写 代做R语言编程|调试Matlab程序uivalent to the pixel values after converting to greyscale - hencethe method name GetGreyIntensity ).Greyscale images: Greyscale images still have RGBA channels, but the values in the RGBchannels are identical. For example, the colour new Rgba32(25, 25, 25, 255) and new Rgba32(80,80, 80, 255) each represent shades of grey. The colour new Rgba32(0, 0, 0, 255) representsblack, and the colour new Rgba32(255, 255, 255, 255) represents white. To convert an image togreyscale, use Image.ToGreyscale(...) .Examplesusing SixLabors.ImageSharp.PixelFormats;  necessary for creating Rgba32 objects... load an imageImage image1 = new Image(cat.png); create an image by copying an old oneImage image2 = new Image(image1); create a black image with a specific width and heightImage image3 = new Image(width: 400, height: 300); get the Rgba32 color of the pixel at x=25, y=30Rgba32 color1 = image1[25, 30]; get the overall pixel intensity at x=25, y=30int intensity = image1.GetGreyIntensity(25, 30); create a color with the values r=50, g=80, b=55, and a=255Rgba32 color2 = new Rgba32(50, 80, 55, 255); create a color that is 5% brighter than another colorRgba32 color3 = new Rgba32((byte)(color1.R * 1.05),(byte)(color2.G * 1.05),(byte)(color2.B * 1.05),(byte)(255)); set a pixel to a new Rgba32 valueimage1[25, 30] = color3;转自:http://www.daixie0.com/contents/18/4660.html

你可能感兴趣的:(讲解:ImageSharp、R、RR|Matlab)