ofPixels, getPixels()

    ofPixels & pixels = bikeIcon.getPixels();   // 모든 픽셀 취득?
    ofSetColor(0, 0, 255);
    // 모든 픽셀에 대해
    for(int y = 0; y < h; y++) {
        for(int x = 0; x < w; x++) {
            int index = y * w + x;
            unsigned char cur = pixels[index];  // 역시 씨불불 이군.
            float size = 1 - ((float) cur / 255);   // 네거티브
            ofDrawCircle(200 + x * diameter, 500 + y * diameter, 1 + size * diameter / 2);  // 픽셀밝기를 반지름으로 바꿔 원들 표시.
        }
    }

댓글

  1. w=h=255;
    img.allocate(w, h, OF_IMAGE_COLOR);
    img.setColor(ofColor::white);
    for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
    ofColor color= ofColor(255-i%w,j%h,255);
    img.setColor(i % w, j % h, color);
    }
    }
    img.update();

    답글삭제
  2. imageToLoad.loadImage("test3.jpg");

    int w = imageToLoad.getWidth();
    int h = imageToLoad.getHeight();

    ofPixels loadedPixels = imageToLoad.getPixels();
    int numChannels = loadedPixels.getNumChannels();

    if(numChannels >= 3)
    {
    for (int i=0; i<w*h; i++)
    {
    currentPixels = imageToLoad.getPixels()[i]
    r_totalPixelVal = r_totalPixelVal + currentPixels.getChannel(0);
    g_totalPixelVal = g_totalPixelVal + currentPixels.getChannel(1);
    b_totalPixelVal = b_totalPixelVal + currentPixels.getChannel(2);
    }
    }
    else
    {
    for (int i=0; i<w*h; i++)
    {
    currentPixels = imageToLoad.getPixels()[i]
    gs_totalPixelVal = gs_totalPixelVal + currentPixels.getChannel(0);
    }
    };

    int numPixels = w*h;

    r_averagePixelVal = (r_totalPixelVal / numPixels);
    g_averagePixelVal = (g_totalPixelVal / numPixels);
    b_averagePixelVal = (b_totalPixelVal / numPixels);

    gs_averagePixelVal = (gs_totalPixelVal / numPixels);

    답글삭제

댓글 쓰기

이 블로그의 인기 게시물

파이썬으로 Homomorphic Filtering 하기

파이썬으로 2D FFT/iFFT 하기: numpy 버전