{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<center>\n",
    "    <tr>\n",
    "    <td><img src=\"ontario-tech-univ-logo.png\" width=\"25%\"></img></td>\n",
    "    </tr>\n",
    "</center>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Fourier Transform for Object Detection\n",
    "\n",
    "Faisal Qureshi   \n",
    "Professor    \n",
    "Faculty of Science    \n",
    "Ontario Tech University    \n",
    "Oshawa ON Canada    \n",
    "http://vclab.science.ontariotechu.ca"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Copyright information\n",
    "\n",
    "&copy; Faisal Qureshi"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## License\n",
    "\n",
    "<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\"><img alt=\"Creative Commons Licence\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc/4.0/88x31.png\" /></a><br />This work is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\">Creative Commons Attribution-NonCommercial 4.0 International License</a>."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Introduction\n",
    "\n",
    "This lab explores object detection using Fourier Transform in the frequency domain. Instead of traditional spatial domain methods (e.g., template matching, feature extraction), we leverage Fourier cross-correlation to detect objects in an image.\n",
    "\n",
    "## Key Concepts\n",
    "\n",
    "- Fourier Transform: Converts an image from spatial to frequency domain.\n",
    "- Cross-Correlation in Fourier Space: Detects objects by comparing the frequency content of an image and a template.\n",
    "- Inverse Fourier Transform: Converts the result back to the spatial domain for visualization."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Recipe\n",
    "\n",
    "Given an image I and a template T\n",
    "\n",
    "1. Load the image and template\n",
    "2. Compute Fourier Transform of the image and the template\n",
    "3. Compute cross-correlation in Fourier Space\n",
    "4. Compute inverse Fourier Transform to get spatial domain correlation\n",
    "5. Find peak detection for object localization\n",
    "6. (Optional) How would you deal with rotations?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Starter Code\n",
    "\n",
    "Check out the sample code at [https://csundergrad.science.uoit.ca/courses/cv-notes/notebooks/05-frequency-analysis.html](https://csundergrad.science.uoit.ca/courses/cv-notes/notebooks/05-frequency-analysis.html) to get started."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Dataset\n",
    "\n",
    "I got the following images from [unsplash.com](unsplash.com).  We use these images for educational purposes only.  Let's see if we are able to count lemons in the last three images.  The first two images can serve as our templates.  Images by Francesco Cantinelli, Hanne Hoogendam, Angelica Echeverry, and eStudio Bloom.  \n",
    "\n",
    "<center>\n",
    "    <tr>\n",
    "    <td><img src=\"04-fourier-space-object-detection/hanne-hoogendam-adLLNTSZVX4-unsplash.jpg\" width=\"25%\"></img></td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "    <td><img src=\"04-fourier-space-object-detection/francesco-cantinelli-6xsotTecOj4-unsplash.jpg\" width=\"25%\"></img></td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "    <td><img src=\"04-fourier-space-object-detection/angelica-echeverry-t261fCT-lEc-unsplash.jpg\" width=\"25%\"></img></td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "    <td><img src=\"04-fourier-space-object-detection/angelica-echeverry-HhVTiioq9DY-unsplash.jpg\" width=\"25%\"></img></td>\n",
    "    </tr>\n",
    "    <tr>\n",
    "    <td><img src=\"04-fourier-space-object-detection/estudio-bloom-ezqnxsqUZ80-unsplash.jpg\" width=\"25%\"></img></td>\n",
    "    </tr>\n",
    "</center>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Submission\n",
    "\n",
    "Your lab will be marked based upon steps 1 to 5 above.  I am under no illusion that we will be able to count lemons.  *Submit via canvas.*    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<center>\n",
    "    <tr>\n",
    "    <td><img src=\"ontario-tech-univ-logo.png\" width=\"25%\"></img></td>\n",
    "    </tr>\n",
    "</center>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
