# OrientedDiffDet: Diffusion Model for Oriented Object Detection in Aerial Images
## 3 Approach
### Proposed Method
#### 3.2.2 Feature Alignment  
The detection decoder takes a set of oriented proposals as input. For each oriented proposal, we use Feature Alignment to extract a fixed-size feature vector from its corresponding feature map. The feature vector is then passed through two fully connected layers, and then two sibling fully connected layers. The output of the first layer is the probability that the proposal belongs to K + 1 classes, where K represents the object classes, and 1 represents the background class. The output of the second layer produces the offsets of the proposal for each of the K object classes.  
Feature alignment is an operation that extracts rotation-invariant features from each oriented box. The oriented proposal created by the oriented RPN often takes the shape of a parallelogram (depicted by the blue box in Figure 3). This parallelogram is defined by the parameters \(\mathbf{v}=(v1,v2,v3,v4)\), where \(v1,v2,v3\), and \(v4\) represent the vertex coordinates. However, for ease of calculations, we need to adjust each parallelogram to a rectangular shape with direction. We achieve this by extending the shorter diagonal (i.e., the line from v2 to v4 in Figure 3) of the parallelogram to have the same length as the longer diagonal. Following this simple operation, we obtain the oriented rectangular shape \((x,y,w,h,\theta)\) (depicted by the red box in Figure 3) from the parallelogram. Here, the parameter \(\theta\in[-\pi/2,\pi/2]\) is defined by the intersection angle between the horizontal axis and the longer side of the rectangular shape.  
To feature align in the remote-sensing object detection, we begin by projecting the oriented rectangle onto the feature map \(\mathbf{F}\) with a stride of s, resulting in an oriented RoL. Subsequently, each oriented Rol is partitioned into a grid of dimensions \(m\times m\) grids (with \(m\) typically set to 7 s). This process yields a fixed-size feature map \(\mathbf{F}^{\prime}\) with dimensions \(m\times m\times C\). Within this feature map, the value of each grid cell indexed by \((i,j)\) in the \(c\)-th channel is computed as follows:  
\[\mathbf{F}^{\prime}_{c}(i,j)=\sum_{(x,y)\in\text{area }(i,j)}\mathbf{F}_{c}(R(x,y, \theta))/n \tag{3}\]  
Figure 2: An example of representation of rotating point box.  
Here, \(\mathbf{F}_{c}\) represents the feature of the \(c\)-th channel, \(n\) denotes the number of samples localized within each grid, and \(\text{ area}(i,j)\) is the set of coordinates included in the grid indexed by \((i,j)\). The function \(R(\cdot)\) represents an oriented RoI, resulting in the sampling points undergoing a rotation offset during bilinear interpolation. The offset values are computed as follows:  
\[x=\tan^{-1}\frac{\frac{h}{2}-\Delta\beta}{\frac{w}{2}+\Delta\alpha}+\text{ center}_{w} \tag{4}\]  
\[y=\tan^{-1}\frac{\frac{h}{2}-\Delta\beta}{\frac{w}{2}+\Delta\alpha}+\text{ center}_{h} \tag{5}\]  
where \(\text{center}_{w}\) and \(\text{center}_{h}\) represent the anchor center coordinates, and the rotation angle \(\theta\) is represented as \(w\), \(h\), \(\Delta\alpha\), and \(\Delta\beta\).