• Event (xodisa) Raqam qiymati
  • 5. OpenCVda tasvirlarni qayta ishlash
  • HighGUI moduli funksiyalari




    Download 6,2 Mb.
    bet23/25
    Sana18.05.2024
    Hajmi6,2 Mb.
    #241708
    1   ...   17   18   19   20   21   22   23   24   25
    Bog'liq
    Lokal binar obrazlar

    4. HighGUI moduli funksiyalari

    Ushbu bo‘limda HighGUI moduli funksiyalari bilan tanishamiz.



    Namoyish oynasini yaratish:
    int cvNamedWindow(const char* name,int flags = CV_WINDOW_AUTOSIZE);

    Tasvirni yuklash:
    IplImage* cvLoadImage(const char* filename,int iscolor = CV_LOAD_IMAGE_COLOR);

    Tasvirni saqlash:
    int cvSaveImage(const char* filename,const CvArr* image);

    Tasvirni namoyish qilish:
    void cvShowImage( const char* name, const CvArr* image );

    Sichqoncha xodisalari (bosilishi):


    void CvMouseCallback(int event,int x,int y,int flags,void* param);

    Bu erda event ga quyidagi xodisalar bog‘langan:




    Event (xodisa)

    Raqam qiymati

    CV_EVENT_MOUSEMOVE

    0

    CV_EVENT_LBUTTONDOWN

    1

    CV_EVENT_RBUTTONDOWN

    2

    CV_EVENT_MBUTTONDOWN

    3

    CV_EVENT_LBUTTONUP

    4

    CV_EVENT_RBUTTONUP

    5

    CV_EVENT_MBUTTONUP

    6

    CV_EVENT_LBUTTONDBLCLK

    7

    CV_EVENT_RBUTTONDBLCLK

    8

    CV_EVENT_MBUTTONDBLCLK

    9



    5. OpenCVda tasvirlarni qayta ishlash

    Tekislash:
    void cvSmooth( const CvArr* src, CvArr* dst, int smoothtype = CV_GAUSSIAN, int param1 = 3, int param2 = 0, double param3 = 0, double param4 = 0 );

    Bu erda Smoothtype o‘zgaruvchisi quyiga tekislash turlarini o‘z ichiga olishi mumkin: CV_BLUR, CV_BLUR_NO_SCALE, CV_MEDIAN, CV_GAUSSIAN, CV_BILATERAL.



    Morfologik Kengaytirish (Dilation):
    void cvErode( IplImage* src, IplImage* dst, IplConvKernel* B = NULL, int iterations = 1 );


    4.5-rasm. Morfologik kengaytirish.

    Morfologik Emirish (Erosion):
    void cvDilate( IplImage* src, IplImage* dst, IplConvKernel* B = NULL, int iterations = 1 );


    4.6-rasm. Morfologik emirish.


    Oqimli to‘ldirish (Flood Fill):
    void cvFloodFill(IplImage* img, CvPoint seedPoint, CvScalar newVal, CvScalar loDiff = cvScalarAll(0), CvScalar upDiff = cvScalarAll(0), CvConnectedComp* comp = NULL, int flags = 4, CvArr* mask = NULL );

    Hajmni o‘zgartirish (Resize):
    void cvResize( const CvArr* src, CvArr* dst, int interpolation = CV_INTER_LINEAR );

    Bu erda Interpolation o‘zgaruvchisi quyidagilarni o‘z ichiga olishi mumkin:CV_INTER_NN, CV_INTER_LINEAR, CV_INTER_AREA, CV_INTER_CUBIC.



    Bo‘sag‘alash (Threshold):
    double cvThreshold( CvArr* src, CvArr* dst, double threshold, double max_value,
    int threshold_type );

    Bu funksiya global bo‘sag‘a qiymati orqali tasvirni bo‘laklash (masalan binarlashtirish orqali) uchun hizmat qiladi. Undagi threshold_type o‘zgaruvchisi quyidagi bo‘sag‘alash turlarinini o‘z ichiga oladi:


    CV_THRESH_BINARY, CV_THRESH_BINARY_INV, CV_THRESH_TRUNC, CV_THRESH_TOZERO_INV, CV_THRESH_TOZERO.

    Adaptiv bo‘sag‘alash (Adaptive Threshold):
    void cvAdaptiveThreshold( CvArr* src, CvArr* dst, double max_val, int adaptive_method = CV_ADAPTIVE_THRESH_MEAN_C, int threshold_type = CV_THRESH_BINARY, int block_size = 3, double param1 = 5 );
    Bu funksiyada bo‘sag‘alash bloklarda, ya’ni kichik sohalarda amalga oshiriladi.

    Quyidagi rasmda (4.7-rasm) berilgan tasvirni global va adaptiv bo‘sag‘alash yordamida binarlashtirish namunalari ko‘rsatilgan.




    4.7-rasm. Berilgan tasvir hamda uning global va adaptiv bo‘sag‘alash natijasi.



    Download 6,2 Mb.
    1   ...   17   18   19   20   21   22   23   24   25




    Download 6,2 Mb.