Click or drag to resize
Accord.NET (logo)

PNMCodec Class

PNM image format decoder.
Inheritance Hierarchy
SystemObject
  Accord.Imaging.FormatsPNMCodec

Namespace:  Accord.Imaging.Formats
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.8.0
Syntax
[FormatDecoderAttribute("pbm")]
[FormatDecoderAttribute("pgm")]
[FormatDecoderAttribute("pnm")]
[FormatDecoderAttribute("ppm")]
public class PNMCodec : IImageDecoder
Request Example View Source

The PNMCodec type exposes the following members.

Constructors
  NameDescription
Public methodPNMCodec
Initializes a new instance of the PNMCodec class
Top
Methods
  NameDescription
Public methodClose
Close decoding of previously opened stream.
Public methodDecodeFrame
Decode specified frame.
Public methodDecodeSingleFrame
Decode first frame of PNM image.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodOpen
Open specified stream.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

The PNM (an acronym derived from "Portable Any Map") format is an abstraction of the PBM, PGM and PPM formats. I.e. the name "PNM" refers collectively to PBM (binary images), PGM (grayscale images) and PPM (color image) image formats.

Image in PNM format can be found in different scientific databases and laboratories, for example Yale Face Database and AT&T Face Database.

Note Note
Only PNM images of P2 (ascii encoded PGM), P3 (ascii encoded ppm), P5 (binary encoded PGM) and P6 (binary encoded PPM) formats are supported at this point.

Note Note
The maximum supported pixel value is 255 at this point.

Note Note
The class supports only one-frame PNM images. As it is specified in format specification, the multi-frame PNM images has appeared starting from 2000.

Examples
string filename = Path.Combine(basePath, "lena.pgm");

// One way to decode the image explicitly is to use
Bitmap image1 = ImageDecoder.DecodeFromFile(filename);

// However, you could also obtain the same effect using
Bitmap image2 = Accord.Imaging.Image.FromFile(filename);
See Also