<p>Maybe you should try to find Virtual Tangent Plane like in <a href="https://arxiv.org/abs/1704.02956" rel="nofollow noreferrer">Surface Normal In the Wild</a></p>

CC BY-SA 3.0
2018-02-01T08:23:23.140Z
2018-02-01T08:23:23.140Z
BlackCode
<p>I want to insert a logo into an RGB image with proper 3D transformations. I can get the estimated pixel normals of this image using the code here: <a href="https://github.com/yindaz/surface_normal" rel="nofollow noreferrer">https://github.com/yindaz/surface_normal</a>. Pixel normals are encoded into RGB channels as described as follows:</p>

<blockquote>
  <p>The estimated normal will be saved in 16-bit PNG format, where 0-65535 in R,G,B channel correspond to [-1, 1] for the X,Y,Z component of the normal vector. We use the camera coordinates defined as - X points to the camera right, Y points to the camera forward, and Z points to the camera upward. For example, right facing wall are very red, floor are very blue, and you rarely see green as it's parallel to the camera viewing direction.</p>
</blockquote>

<p>How can I transform the 2D logo to put it onto a planar surface in the image? I have tried to calculate the rotation angles of the normal to rotate it so that it has the same direction as the camera normal, and rotate the logo according to these angles, but I have no success so far.</p>

<p>As far as I understand from the quote above, normal of the untransformed logo should be $(x:0, y:-1, z:0)$ and let the pixel normal be $(x:a, y:b, z:c)$ with magnitude $M$. I rotate the logo around $X$ by $arccos(a/M)*180/pi$, around $Y$ by $arccos(b/M)*180/pi$, around $Z$ by $arccos(c/M)*180/pi$, and if $b &lt; 0$ rotate around $Y$ by an additional 180 degrees.</p>

<p>Is there anything reasonable in these? Is it possible that I can do this using the estimated normals?</p>

CC BY-SA 3.0
2018-01-31T15:35:36.560Z
You need to search for "Homography".  Estimate a homography that places the image in the scene based on the normals and transform your image by the homography.
Wyck
CC BY-SA 3.0
2018-02-01T05:07:23.783Z
So it is possible to estimate a homography using normals, right? I have found homography estimation using two images or through finding vanishing points in a single image so far, but not using normals. Is there a specific term for this that I should search for?
groove
CC BY-SA 3.0
2018-02-02T02:41:47.837Z
I assume the normals help you estimate depth so that you get 3d points.  You don't need that if the surface is planar though.  Just identify the four corners of the rectangle that you want to map in the target image and use the homography.
Wyck
CC BY-SA 3.0
2018-02-05T13:03:01.603Z
This would work only if there is a rectangle and it can be found, right? I need to find areas with no semantically significant content, such as empty walls, and insert a logo there. I couldn't succeed using corner detection-based methods or homography estimation using parallel lines. Therefore I though surface normals can be useful since there is a normal for each pixel.
groove
CC BY-SA 3.0
2018-02-05T14:18:40.407Z
Normals are as useful as derivatives in Calculus.  Much like how you can integrate derivatives to get the original function (+/- a constant), you can do something similar to your normals to get the original surface (+/- a global translation). But knowing the geometry of the surface doesn't describe WHERE you want to put your image on that surface.  I feel like I still don't understand how you want to describe where the image goes.  But I also feel like you can bypass the problem if you use the homography.
Wyck
<transformations><affine-transformations>
Image warping using pixel normals
groove
# Image warping using pixel normals

(Asked by: username_0 on 2018-01-31)

I want to insert a logo into an RGB image with proper 3D transformations. I can get the estimated pixel normals of this image using the code here: <https://github.com/yindaz/surface_normal>. Pixel normals are encoded into RGB channels as described as follows:

> The estimated normal will be saved in 16-bit PNG format, where 0-65535 in R,G,B channel correspond to [-1, 1] for the X,Y,Z component of the normal vector. We use the camera coordinates defined as - X points to the camera right, Y points to the camera forward, and Z points to the camera upward. For example, right facing wall are very red, floor are very blue, and you rarely see green as it's parallel to the camera viewing direction.

How can I transform the 2D logo to put it onto a planar surface in the image? I have tried to calculate the rotation angles of the normal to rotate it so that it has the same direction as the camera normal, and rotate the logo according to these angles, but I have no success so far.

As far as I understand from the quote above, normal of the untransformed logo should be $(x:0, y:-1, z:0)$ and let the pixel normal be $(x:a, y:b, z:c)$ with magnitude $M$. I rotate the logo around $X$ by $arccos(a/M)\*180/pi$, around $Y$ by $arccos(b/M)\*180/pi$, around $Z$ by $arccos(c/M)\*180/pi$, and if $b < 0$ rotate around $Y$ by an additional 180 degrees.

Is there anything reasonable in these? Is it possible that I can do this using the estimated normals?

**Tags:** transformations, affine-transformations

> **Comments:**
> **username_1**: You need to search for "Homography".  Estimate a homography that places the image in the scene based on the normals and transform your image by the homography.  
> **username_0**: So it is possible to estimate a homography using normals, right? I have found homography estimation using two images or through finding vanishing points in a single image so far, but not using normals. Is there a specific term for this that I should search for?  
> **username_1**: I assume the normals help you estimate depth so that you get 3d points.  You don't need that if the surface is planar though.  Just identify the four corners of the rectangle that you want to map in the target image and use the homography.  
> **username_0**: This would work only if there is a rectangle and it can be found, right? I need to find areas with no semantically significant content, such as empty walls, and insert a logo there. I couldn't succeed using corner detection-based methods or homography estimation using parallel lines. Therefore I though surface normals can be useful since there is a normal for each pixel.  
> **username_1**: Normals are as useful as derivatives in Calculus.  Much like how you can integrate derivatives to get the original function (+/- a constant), you can do something similar to your normals to get the original surface (+/- a global translation). But knowing the geometry of the surface doesn't describe WHERE you want to put your image on that surface.  I feel like I still don't understand how you want to describe where the image goes.  But I also feel like you can bypass the problem if you use the homography.  

---

## 1 answers

### Answer by username_2 on 2018-02-01. Score: -1

Maybe you should try to find Virtual Tangent Plane like in [Surface Normal In the Wild](https://arxiv.org/abs/1704.02956)


---

