Forums - How to mosaic an rectangle area

3 posts / 0 new
Last post
How to mosaic an rectangle area
371152061
Join Date: 13 May 22
Posts: 11
Posted: Tue, 2022-06-14 07:10

Hi, 

    I want to mosaic an area( such as an rectangle or  ellipse),  can anyone tell me how to implement it?

   for rectangle(an RGB array set to gray), it doesnt work

int pos = x_pos+ y_pos;
fcvSetElementsc3u8(data+pos, dst_width, dst_height, stride, 128, 128, 128, NULL, 0);

 

 

  • Up0
  • Down0
371152061
Join Date: 13 May 22
Posts: 11
Posted: Wed, 2022-06-15 01:20

I use pure math to implement rectangle mosaic.

static void mosaic_rectangle(uint8_t* src, int src_w,int startX, int startY, int w, int h)
{
    uint8_t* line = (uint8_t*) fcvMemAlloc(w*3, 16);
    memset(line, 128, w*3);
    for(int i=0; i<h; i++){
        int pos = startY*(src_w*3)+(src_w*3)*i  + startX*3;
        memcpy(src+pos, line, w*3);
    }
    fcvMemFree(line);
}

 

can give me some implementation advice for ellipse or circle? 

  • Up0
  • Down0
ss.pandiri
Join Date: 29 May 18
Posts: 56
Posted: Thu, 2022-07-28 07:03

hi,

Once you know the centre of the circle (coordinates)and its radius (coordinates) in your picture you can use the equation:

x^2 + y^2 = R^2 to determine whether a particular point (given by x, y) lies on a circle of radius (R).

You can use root of (x^2 + y^2) to know whether the point lies inside or outside the circle. if (root of (x^2 + y^2)) is greater than R then the point (x,y) lies outside the circle else inside.

https://study.com/skill/learn/determining-if-a-point-lies-inside-outside....

thanks 

 

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.