StartseiteProgrammingConvert RGB to HSV and back with a micro controller

Kommentare

Convert RGB to HSV and back with a micro controller — 4 Kommentare

  1. Since this is one of the popular search results, I’ll provide some informations on opencv. The images are internaly stored as arrays. For regular image, it’s RGB format, RGBA or some more exotic. To extract regular RGB, you can use this code:

    Mat image = imread(„input.jpg“, CV_LOAD_IMAGE_COLOR); // Or whatever settings
    if (!image.data) { // Valid image
    byte[] data = image.data; // Pixel array
    unsigned int totalPixels = image.rows*image.cols;
    struct RGB_set RGB; // RGB structure
    struct HSV_set HSV; // HSV structure
    for(int i=0;i<totalPixels;i++) { // For every pixel in image
    RGB.r = input_data[(i * 3) + 2];
    RGB.g = input_data[(i * 3) + 1];
    RGB.b = input_data[(i * 3) ];
    printf ("Yellow in RGB: %X, %X, %X\n", RGB.r, RGB.g, RGB.b);
    RGB2HSV(RGB, &HSV);
    printf ("converted to HSV: %X, %X, %X\n", HSV.h, HSV.s, HSV.v);
    }
    }

  2. I was searching for a simple, straightforward function to convert RGB vales to HSV, and you provided it.

    The code worked faultlessly without any modification in the Arduino IDE. Just what I was looking for, Thank You!

    If I end up using your code in a project I plan on sharing in a YouTube video, I will definitely be crediting you, and providing a link to this page.

    • I am sorry, but I don’t have or use the opencv library! I would expect it already has functions for this very trivial conversions. Else make your own function with your code.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

 

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.

HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>