1 | initial version |
however, i think, we can help you with your alpha mask.
this is basically a 2d gaussian distribution, used as a vignette
it's a bit clumsy, using java but something like this:
Size s = image.size();
double sigma = 45.0;
double cutoff = 900;
Mat vert = Imgproc.getGaussianKernel(200, sigma, CvType.CV_64F);
Mat horz = Imgproc.getGaussianKernel(200, sigma, CvType.CV_64F);
Mat vignette = new Mat();
Core.gemm(vert,horz, 1, new Mat(), 0, vignette, Core.GEMM_2_T);
Core.normalize(vignette,vignette, cutoff*255, 0, Core.NORM_L2, CvType.CV_8U);
Imgproc.resize(vignette,vignette,0,0);
will result in an image like:
then you can split the image into channels, and merge the vignette as alpha channel:
List<Mat> chn = new ArrayList<Mat>();
Core.split(ocv,chn);
chn.add(vignette);
Core.merge(chn,ocv);
2 | No.2 Revision |
however, i think, we can help you with your alpha mask.
this is basically a 2d gaussian distribution, used as a vignette
it's a bit clumsy, using java but something like this:
Size s = image.size();
double sigma = 45.0;
double cutoff = 900;
Mat vert = Imgproc.getGaussianKernel(200, sigma, CvType.CV_64F);
Mat horz = Imgproc.getGaussianKernel(200, sigma, CvType.CV_64F);
Mat vignette = new Mat();
Core.gemm(vert,horz, 1, new Mat(), 0, vignette, Core.GEMM_2_T);
Core.normalize(vignette,vignette, cutoff*255, 0, Core.NORM_L2, CvType.CV_8U);
Imgproc.resize(vignette,vignette,0,0);
Imgproc.resize(vignette,vignette,s,0,0);
will result in an image like:
then you can split the image into channels, and merge the vignette as alpha channel:
List<Mat> chn = new ArrayList<Mat>();
Core.split(ocv,chn);
chn.add(vignette);
Core.merge(chn,ocv);
3 | No.3 Revision |
however, i think, we can help you with your alpha mask.
this is basically a 2d gaussian distribution, used as a vignette
it's a bit clumsy, using java but something like this:
Size s = image.size();
double sigma = 45.0;
double cutoff = 900;
Mat vert = Imgproc.getGaussianKernel(200, sigma, CvType.CV_64F);
Mat horz = Imgproc.getGaussianKernel(200, sigma, CvType.CV_64F);
Mat vignette = new Mat();
Core.gemm(vert,horz, 1, new Mat(), 0, vignette, Core.GEMM_2_T);
Core.normalize(vignette,vignette, cutoff*255, 0, Core.NORM_L2, CvType.CV_8U);
Imgproc.resize(vignette,vignette,s,0,0);
will result in an image like:
then you can split the image into channels, and merge the vignette as alpha channel:
(this assumes, the image had 3 channels. if you have 4, you have to throw away the 4th channel before merging)
List<Mat> chn = new ArrayList<Mat>();
Core.split(ocv,chn);
chn.add(vignette);
Core.merge(chn,ocv);