0

Can anybody tell me the correct java code for this c++ code snippet:

output.at(x, y) = target.at(dx, dy);

I have tried this java code and they are displacing pixel but not showing image clearly :

output.put(x, y, target.get(dx, dy));

1 Answers1

0

For one channel images e.g. grey-scale; 0 ~ 255

Getting a pixel value

double pixelValue = image.get(i,j)[0];

Setting a pixel value

image.put(i,j,230);

For 3 channel images e.g. RGB (3 values 0 ~ 255)

Getting a pixel (double[] array will have 3 values)

double[] pixelValue = image.get(i,j);

Setting a pixel with 3 RGB values

image.put(i,j,255,250,100); // yellow color
arxakoulini
  • 723
  • 7
  • 22
  • sorry i'm newbie to opencv and image processing but here i am reciveing error :Provided data element number (1) should be multiple of the Mat channels count (4) – Udaib Khan Mar 16 '18 at 10:57
  • good it's start working, can you please tell me how to set this : output.put(y, x, ((backgroundPx * (1. - opacity)) + (foregroundPx * opacity))); – Udaib Khan Mar 16 '18 at 16:24
  • What is your error/problem you are facing? Also, please consider setting my answer as 'accepted'. – arxakoulini Mar 16 '18 at 16:26