Ask Your Question

arqam's profile - activity

2021-08-25 05:00:31 -0600 received badge  Popular Question (source)
2020-06-16 09:10:22 -0600 received badge  Famous Question (source)
2019-04-30 05:33:40 -0600 received badge  Notable Question (source)
2019-04-10 09:48:42 -0600 received badge  Popular Question (source)
2018-12-17 16:02:34 -0600 marked best answer Performing Filter in a specific part of the image

The defined method for filters example binary filter takes two parameters, the source image MAT and destination image MAT and performs filter on the full image.

But what if I want to perform operations like filter in only a part of the image for which we have the contour points (either Point or MatOfPoint).

The solution that I am looking for is in JAVA.

2018-10-09 17:26:26 -0600 received badge  Student (source)
2017-08-29 01:07:13 -0600 asked a question Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib

Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib I opened my working Java openCV project and I got the follow

2017-08-06 00:10:25 -0600 asked a question How to use Bilateral Filter in a submat

I mean the JAVA api for Bilateral Filter the source and destination Mat cannot be same.

So we have to clone the submat and store the result in that Mat. But then we will not be able to see the original result in the main image. Also if we copy this cloned submat back again then also we are not able to see the result.

So my question is in the case of submat how can we do Bilateral filter and apply to the result.?

2017-08-05 07:40:08 -0600 asked a question Poison Image Editing

In openCV is there any API that is performing this operation, have looked but till now nothing relatable to this can be found.

Poison image Editing is used for seamless copying of a part of image to another image. Examples : https://github.com/cheind/poisson-ima...

Paper : https://www.cs.jhu.edu/~misha/Fall07/...

2017-08-04 05:13:37 -0600 asked a question How to replace a bigger rect with a smaller rect

I am doing some operation where I need to replace the bigger rectangle with the smaller rectangle.

Most answers suggested to use smallerRectMat.copyTo(biggerRectMat) but it didn't give me the require output. The submat is changed but the original image is as it is.

And whe I try to see the submat both became same of same smaller rectangle size .

Mat rectNose = testBuffer.submat(rectA.y,rectA.y+rectA.height,rectA.x,rectC.x+rectC.width);
    Rect biggerRect = getHeadContour(testBuffer);
    Mat rectHead = testBuffer.submat(biggerRect.y+1,biggerRect.y+biggerRect.height,biggerRect.x+1,biggerRect.x+biggerRect.width);
    rectNose.copyTo(rectHead);
    Imgcodecs.imwrite("/Users/test.jpg",rectHead);
    Imgcodecs.imwrite("/Users/test1.jpg",rectNose);
 Imgcodecs.imwrite("/Users/test1.jpg",testBuffer);

Here both rectHead and rectNose become same but no change in the testBuffer. Any possible way how it can be done?

2017-08-03 08:44:08 -0600 commented question Applying a particular texture in an image ROI

@KjMag In general how a problem like this is tackled?

2017-08-03 08:20:16 -0600 commented question Applying a particular texture in an image ROI

@KjMag Have edited, please check the question.

2017-08-03 08:12:29 -0600 commented question Applying a particular texture in an image ROI

@KjMag the texture is rectangle but the contour is forehead shape. If you will scroll down the paper link that I gave and check fig 7c and 7e.

2017-08-03 08:01:55 -0600 commented question Applying a particular texture in an image ROI

@KjMag no its not a rectangular area.

2017-08-03 07:36:30 -0600 asked a question Applying a particular texture in an image ROI

So I am going through this paper : http://140.118.9.222/publications/jou...

If you look in the image 7c and 7e, they have the texture image in 7c and that is applied over the forehead.

So my question being if we have a particular texture how to apply that to an image region whose we know the contour points in openCV?

image description

2017-08-03 06:19:52 -0600 commented answer Getting null value for image pixel

Nothing special, Mat lumB = srcImage.submat(rectB.y,rectB.y+rectB.height,rectB.x,rectB.x); Core.MinMaxLocResult result = Core.minMaxLoc(srcImage); And then it gives me error.

2017-08-03 06:13:25 -0600 commented answer Getting null value for image pixel

For minMaxLoc it gives the error Assertion failed ((cn == 1 && (_mask.empty() || _mask.type() == CV_8U)) || (cn > 1 && _mask.empty() && !minIdx && !maxIdx)) in minMaxIdx, We just need to pass a submat right?

2017-08-03 05:51:56 -0600 commented answer Getting null value for image pixel

Is it possible to just get the row value using submat()?

2017-08-03 04:59:04 -0600 commented answer Getting null value for image pixel

Any way of getting the highest Y value of the pixel without parsing all the pixels?

2017-08-03 04:36:10 -0600 commented answer Getting null value for image pixel

And why should it be img.get(y,x) and not (x,y) as in the documentation it says (rows,columns)

2017-08-03 04:28:02 -0600 commented answer Getting null value for image pixel

In Java its not. Just 127, here I need to find the highest Y value for the color space YcrCb.

2017-08-03 04:20:06 -0600 commented answer Getting null value for image pixel

but what is some values are more than 127, then we can't use byte right

2017-08-03 04:08:16 -0600 asked a question Getting null value for image pixel

I have an image and when I try to get the pixel value using

srcImage.get(x,y,buffer) and if the buffer is of a double data type I get null values in many cases and when the data type is changed to byte[] I don't get null.

My image is in YCrCb format. Any possible reason for this problem?

2017-08-03 02:46:07 -0600 asked a question How to find the average pixel value for a rectangular region

I have a rectangular region in an image and have to calculate the average value.

One way I can do is parsing through each pixel value to calculate the average, but that is not an efficient way. Is there any better approach to do in openCV, preferably JAVA.

2017-08-03 00:45:26 -0600 asked a question Linear Interpolation meaning

I am going through a paper in computer vision, and I come through this line :

the L values, or the luminance values, for
these pixels are then linearly and horizontally interpolated between
the pixels on the (one pixel wide) brightest column in region B, and
the pixels in regions A and C.

So, what does linear and horizontal interpolation actually mean wrt image processing?

Paper : http://140.118.9.222/publications/jou...

2017-07-21 00:43:16 -0600 commented question Getting negative value of pixel openCV Java

@berak How is it get(y,x) when the we are parsing srcImage.rows for x and srcImage.cols for y?

2017-07-20 21:39:37 -0600 asked a question Applying filter with a Mask

I have an image and a mask, where I want to do filter/blur operations only at the region where the mask is white i.e the mask has value 255 and not where mask has 0.

I tried using these operation :

erode(maskImage,maskImage,Mat()); // values near irrelevant pixels should not be changed
blur(sourceImage,bluredImage,Size(3,3));
bluredImage = sourceImage + ((bluredImage-sourceImage) & maskImage);

But the & operation cannot be performed in images with different channels.

And when I tried with the accepted answer from here http://answers.opencv.org/question/30... it gave me completely black image.

So how can I do operations with a mask as a parameter?

2017-07-20 21:34:55 -0600 commented answer Smoothing with a mask

How can you do the & operation, when the number of channels is not same.

2017-07-20 04:35:42 -0600 asked a question Perfecting inpainting for removing eyes

What I am trying to achieve is get a face where I have with removing eyes, eyebrows and lips replaced with skin in that area.

For that I am using inpainting, but results are not perfect.

Inpainted Image :

image description

Original Image :

image description

I have contour regions around eyes, brows, and lips like this :

image description

So what I am looking for is a perfect smoothness so that no blurriness is there around the region being inpainted, possible different approach for this is welcome :)

2017-07-17 02:53:34 -0600 asked a question Frequential Analysis in openCV

I am going through a research paper and trying to implement it. In the paper it is saying :

That they use the isotrope Gaussian bandwidth Filter, giving a formula and then using the formula they get the frequential map.

My question being, how to apply a particular formula to the matrix image (Section 3.2), and what is the frequential map, as in what format it is?

Link for the paper : Frequential and color analysis for hair mask segmentation

PS : Its difficult for me to write the equation over here, so please bear with me.

image description

2017-07-11 06:57:54 -0600 commented question Reading PNG images not giving alpha values

@berak, Hehe, no, email ID or something I needed to discuss something (Not a doubt or something)

2017-07-11 06:47:55 -0600 commented question Reading PNG images not giving alpha values

@berak Can I get your contact ID?

2017-07-11 04:52:31 -0600 commented question Reading PNG images not giving alpha values

@berak The image that I downloaded is of png format. When reading using imread it doesn't show the alpa value. So is there anywhere I am going wrong?

2017-07-11 04:36:59 -0600 commented question Reading PNG images not giving alpha values

@berak the submat gives : Mat [ 50*50*CV_8UC3, isCont=false, isSubmat=true, nativeObj=0x7ff53d533800, dataAddr=0x1248e7576 ] So how is a png image having 3 channels, shouldn't it have 4 channels with one being alpha?

2017-07-11 04:21:52 -0600 asked a question Reading PNG images not giving alpha values

I am trying to read a png image but I don't see the alpha values when I parse through the image.

Mat srcImage = Imgcodecs.imread("image_matting_example.png", IMREAD_UNCHANGED);
        byte[] buffer = new byte[4];
        Mat alphaOne = srcImage.clone();
        for(int x=100;x<440;x++){
            for(int y=20;y<60;y++){
                alphaOne.get(x,y,buffer);;
            }
        }

Here the code gives me an error as the buffer array value that I get is having just 3 values which is actually BGR(or RGB) but I am not able to see the Alpha channel, so any reason why this error is happening?

2017-07-10 15:58:20 -0600 asked a question Core.compare openCV

As per the openCV documentation it states that Core.Compare(Mat src1, Scalar src2, Mat dst, int cmpop) Performs the per-element comparison of two arrays or an array and scalar value.

So in the above line what does comparison actually mean?

Like if we take an example with :

Mat source = new Mat(1, 1, CvType.CV_8U, new Scalar(3));
Mat mask = new Mat();
Imgproc.grabCut(srcImage,mask,rect,new Mat(),new Mat(),3,Imgproc.GC_INIT_WITH_RECT);
Core.compare(mask, source,mask, Core.CMP_EQ);

The above makes the mask to be in the visible form which can be seen as an image. So what did Core.compare actually do?

2017-07-10 14:35:01 -0600 commented question Grabcut foreground problem

@berak Yeah, and in grabcut it is strange to see when I change my value from 3(Probable foreground) to 1(foreground) in the mask it makes it background.

2017-07-10 09:11:25 -0600 commented question Grabcut foreground problem

@berak Okay, and the value defines the intensity right?

2017-07-10 08:17:03 -0600 commented question Grabcut foreground problem

@berak They are already 3 in there. When I do Mat.get(x,y) I get a byte array having 3 values. Can you please tell what are these values as in 3 channels? Are these 3 color channels RGB and the value signifies intensity of that channel or something else?

2017-07-10 07:19:17 -0600 asked a question Grabcut foreground problem

Grabcut works on the method that we define the pixel of our image as sure foreground or sure background in our mask. And then try to iterate to see the result.

In my case when I define certain pixel as background it takes that properly but when I define a certain pixel as foreground it changes the result to background(black).

Any possible reason why this is happening :

for(int x=419;x<438;x++){
        for(int y=317;y<456;y++){
            result.get(x,y,buffer);
            buffer[0] = 1;
            result.put(x,y,buffer);
        }
    }
    Imgproc.grabCut(srcImage,result,rect,new Mat(),new Mat(),10,Imgproc.GC_INIT_WITH_MASK);

Which gives that blackish mark in middle of the face as you can see (same result for hair part which I marked as sure background value of 0). Any possible reason why its happening?

image description

2017-07-10 07:12:33 -0600 answered a question Mask giving assertion error in Grabcut Algo

That means that the mask that you are passing is having some points which is not having one of the four values specified for the mask to be passed in grabcut function.

When you use Imgproc.GC_INIT_WITH_MASK you should have the mask with any of the four values. For case when you use Imgproc.GC_INIT_WITH_RECT you can have an empty mask also.

So for solving your problem make sure that your mask has either 0,1,2 or 3 meaning background, foreground, probable background, probable foreground respectively.

2017-07-10 06:00:55 -0600 commented question How to separate the hair out of this image using opencv

Try grabcut.

2017-07-09 14:34:52 -0600 asked a question Getting negative value of pixel openCV Java

In a java project when trying to access pixel value, I am getting negative value.

Code ::

Mat srcImage = imageToMatFormat(imgSource);
    byte[]  buffer = new byte[3];
    for (int x = 0; x < srcImage.rows(); x++) {
        for (int y = 0; y < srcImage.cols(); y++) {
            srcImage.get(x, y, buffer);
            if(buffer[0]!=0)
                System.out.println(buffer[0] + buffer[1] + buffer[2]);
        }
    }

Some values that I am getting is

126-119-115
125-120-116
124-121-117

So what does this negative number in here signi