Learn Load, Display In Addition To Relieve An Image


Mat imread(const string& filename, intflags=1 )
Parameters:
  • filename – Name of file to live on loaded.
  • flags –Flags specifying the color type of a loaded image:
    • CV_LOAD_IMAGE_ANYDEPTH - render 16-bit/32-bit icon when the input has the corresponding depth, otherwise convert it to 8-bit.
    • CV_LOAD_IMAGE_COLOR(>0) - If set, ever convert icon to the color one
    • CV_LOAD_IMAGE_GRAYSCALE (0)- If set, ever convert icon to the grayscale one
    • CV_LOAD_IMAGE_UNCHANGED (<0) loads the icon equally is (including the alpha channel if present)
bool imwrite(const string& filename, InputArray img, const vector<int>&params=vector<int>() )
Parameters:
  • filename – Name of the file.
  • image – Image to live on saved.
  • params – Format-specific relieve parameters encoded equally pairs paramId_1, paramValue_1, paramId_2, paramValue_2, ... . The next parameters are currently supported:
    • For JPEG, it tin live on a lineament (CV_IMWRITE_JPEG_QUALITY ) from 0 to 100 (the higher is the better). Default value is 95.
    • For PNG, it tin live on the compression marking (CV_IMWRITE_PNG_COMPRESSION) from 0 to 9. Influenza A virus subtype H5N1 higher value agency a smaller size as well as longer compression time. Default value is 3.
    • For PPM, PGM, or PBM, it tin live on a binary format flag (CV_IMWRITE_PXM_BINARY ), 0 or 1. Default value is 1.
void imshow(const string& winname, InputArray mat)

Parameters:
  • winname – Name of the window.
  • image – Image to live on shown.

Steps:

  1. Load icon using imread().
  2. Display icon using namedWindow() as well as imshow().
  3. Save the icon using imwrite().
  4. Wait for keyboard push press using waitKey().

Example:

--------------
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream>  using namespace cv; using namespace std;  int main( ) {         Mat image;         // LOAD icon        icon = imread("image1.jpg", CV_LOAD_IMAGE_COLOR);   // Read the file "image.jpg".               //This file "image.jpg" should live on inwards the projection folder.               //Else furnish amount address : "D:/images/image.jpg"         if(! image.data )  // Check for invalid input        {               cout <<  "Could non opened upwards or detect the image" << std::endl ;               render -1;        }         //DISPLAY icon        namedWindow( "window", CV_WINDOW_AUTOSIZE ); // Create a window for display.        imshow( "window", icon ); // Show our icon within it.         //SAVE icon        imwrite("result.jpg",image);// it volition shop the icon inwards mention "result.jpg"         waitKey(0);                       // Wait for a keystroke inwards the window        render 0; }
--------------

Sources:
http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html

Comments

Popular posts from this blog

Accueil Technologie Ct 1.2 - Frauder Une Ou Des Hypothèses Rasé Matérialiser À Une Croix Ou À Un Irradiant Démarquage

Accueil Technologie Ct 1.1 - Imaginer, Synthétiser, Formaliser Et Engorger Une Procédure, Un Protocole.

Accueil Technologie Satisfecit Exonérer Ma Spontanément ?