Ask Your Question
1

modifying pixel value

asked Apr 26 '13

hayden gravatar image

Hello every body, after loading picture, i would like to modify the pixel values and write it back i.e. the modified image. Could any one give me some hint how can that be done. Thanks.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
2

answered Apr 27 '13

wuling gravatar image

updated Apr 27 '13

Hi,I use Mat format. If you have a gray picture & change a pixel. like:

 image.at<uchar>(i,j)=valve// where i is image row & j is image cols & 0<=value<=255

if you want to change all picture value:

for(int y = 0; y < image.row; y++)
    for(int x = 0 < image.col; x++)
    {
       ..............
        imageB.at<uchar>(y,x)=saturate_cast<uchar>(operator(image.at<uchar>(y,x)))
         //where operator is image processing algorithm
       ............
    }

& please ref Mat::isContinuous and other Mat operator :http://docs.opencv.org/modules/core/doc/basic_structures.html

If you want lower cost time. I think you should ref opencv code:SSE & AVX or CUDA

Preview: (hide)

Comments

how can i modify pixel value from 0 to 0.01 ?

Deepak Kumar gravatar imageDeepak Kumar (Nov 14 '14)edit

Question Tools

Stats

Asked: Apr 26 '13

Seen: 11,915 times

Last updated: Apr 27 '13