Computer Vision Interview Questions

Last Updated : 23 Jul, 2026

Computer vision is a field of artificial intelligence that enables machines to interpret and understand visual information from the world. It encompasses a wide range of tasks such as image classification, object detection, image segmentation and image generation.

1. Explain the concept of pixels and image resolution.

A pixel (short for picture element) is the smallest unit of a digital image. Each pixel holds a value representing color or intensity and when combined with millions of other pixels, it forms a complete image. Image resolution, on the other hand, refers to the amount of detail an image holds.

  • Each pixel may represent grayscale intensity (0–255) or color values (RGB).
  • Resolution can be measured in: Spatial resolution (width × height in pixels) and Pixel density (PPI or DPI for print).
  • High resolution provides more detail but requires more storage and processing.
  • Low resolution results in pixelation when images are enlarged.
  • Common resolutions: 720p (HD), 1080p (Full HD), 4K (Ultra HD).

2. What are the common color spaces used in image processing (RGB, HSV, LAB, YCbCr)?

A color space is a specific way of representing color numerically. Different tasks in computer vision benefit from different color spaces because they separate color information (chrominance) from brightness (luminance) differently.

  • RGB (Red, Green, Blue): The default color space for most cameras and displays. Each pixel is represented as a combination of three channels.
  • HSV (Hue, Saturation, Value): Separates color (Hue) from intensity (Value) and color purity (Saturation). Useful for color-based segmentation since it is more robust to illumination changes than RGB.
  • LAB (CIELAB): Separates lightness (L) from color information . Designed to be perceptually uniform, meaning equal distances in LAB space correspond to equal perceived color differences.
  • YCbCr: Separates luma (Y, brightness) from chroma (Cb, Cr, color). Widely used in video compression (JPEG, MPEG) because the human eye is more sensitive to brightness than color, allowing chroma channels to be compressed more aggressively.

3. Explain the 2D Discrete Fourier Transform (DFT).

The 2D Discrete Fourier Transform (DFT) is a way to convert a 2D image from its spatial form (pixels) into the frequency domain. In the frequency domain, we can see which patterns or details (like edges or textures) are present in the image.

  • The 2D DFT of an image f(x,y) of size M \times N is:

F(u,v) = \sum_{x=0}^{M-1} \sum_{y=0}^{N-1} f(x,y) \cdot e^{-j 2 \pi \left(\frac{ux}{M} + \frac{vy}{N}\right)}

  • Converts the image from the spatial domain to the frequency domain.
  • Each F(u,v) represents a specific frequency’s magnitude and phase.
  • Useful for low-pass or high-pass filtering, edge detection and image compression.
  • Direct computation of DFT is slow for large images.

4. How does the Fast Fourier Transform (FFT) improve over DFT?

The Fast Fourier Transform (FFT) is a faster way to compute the DFT. Normally, calculating DFT for an N \times N image takes O(N^4) operations in 2D. It does this by breaking the problem into smaller parts and reusing calculations. This makes FFT very practical for real-time image and signal processing.

  • FFT makes DFT computation much faster, especially for large images.
  • Most software libraries (like NumPy or MATLAB) use FFT under the hood.
  • Allows real-time processing for audio, video and images.
  • Preserves the same accuracy as DFT while improving efficiency.

5. What is convolution in image processing and why is it important?

Convolution is a fundamental operation in image processing where a small matrix, called a kernel or filter, is applied over an image to extract certain features or modify the image.

  • It works by sliding the kernel across the image and performing element-wise multiplication followed by summation to produce a new value for each pixel.
  • Most image processing and computer vision techniques rely on convolution for analyzing patterns in images.
  • A kernel (or filter) is a small matrix like 3×3 or 5×5 that defines the operation (e.g., smoothing, detecting edges).
  • The convolution operation at pixel (x,y) is:

g(x,y) = \sum_{i=-k}^{k} \sum_{j=-k}^{k} f(x-i, y-j) \cdot h(i,j)

Where f(x,y) is the input image, h(i,j) is the kernel and g(x,y) is the output image.

Convolution can be used for:

  • Smoothing/Blurring: Reduces noise and softens images.
  • Sharpening: Highlights edges and fine details.
  • Edge Detection: Finds boundaries in images (e.g., Sobel, Prewitt filters).
  • Feature Extraction: Helps in object recognition and deep learning.

6. What is correlation and how does it differ from convolution?

Correlation and Convolution are mathematical operations used in signal processing and deep learning.

Correlation

  • Correlation measures the similarity between two signals or datasets.
  • The filter (kernel) is applied without flipping.
  • It identifies where a pattern best matches the input.
  • It is commonly used in template matching, pattern recognition, and signal analysis.
  • Goal: Measure how closely two signals or patterns match.

Convolution

  • Convolution combines an input signal with a kernel (filter) to produce a transformed output called a feature map.
  • In the mathematical definition, the kernel is flipped (rotated by 180° in 2D) before sliding over the input.
  • It extracts important features such as edges, textures, and shapes.
  • It is the core operation in Convolutional Neural Networks (CNNs), image processing, and signal processing.
  • Goal: Extract meaningful features from the input.

7. What are linear and non-linear filters? Give examples.

Filters are used in image processing to modify an image, either to enhance features, remove noise or detect edges. Filters are classified into linear and non-linear based on how the output pixel is computed from its neighborhood.

Linear Filters: A linear filter computes each output pixel as a weighted sum of its neighboring pixels. These filters follow the principles of linearity and superposition, meaning the output changes proportionally to the input. Linear filters are mainly used for smoothing, sharpening and edge detection.

Formula (2D linear filter):

g(x,y) = \sum_{i=-k}^{k} \sum_{j=-k}^{k} f(x-i, y-j) \cdot h(i,j)

Where:

  • f(x,y) = input image
  • h(i,j) = filter/kernel
  • g(x,y) = output image

Examples:

  • Averaging filter: Smooths image by averaging neighbors.
  • Gaussian filter: Smooths image using Gaussian weights (reduces noise).
  • Laplacian filter: Highlights edges using second-order derivatives.

Pros: Simple, efficient, good for smoothing/sharpening.

Cons: Can blur edges and fine details.

Non-Linear Filters: A non-linear filter computes each output pixel using a non-linear function of neighboring pixels. These filters are effective for noise removal while preserving edges and details.

Examples:

  • Median filter: Replaces pixel with median of neighbors (removes salt-and-pepper noise).
  • Max/Min filter: Replaces pixel with maximum/minimum value in neighborhood.
  • Bilateral filter: Smooths image while keeping edges sharp (considers spatial and intensity differences).

Pros: Preserves edges, effective against impulsive noise.

Cons: Slightly more computationally expensive than linear filters.

8. Explain Gaussian filtering and its purpose.

Gaussian filtering is a type of linear smoothing filter used to reduce noise and blur an image in a controlled way. It uses a Gaussian function to assign weights to neighboring pixels, giving more importance to pixels near the center and less to those farther away. Gaussian filtering is widely used in image preprocessing, edge detection and computer vision tasks because it smooths images without introducing sharp artifacts.

Gaussian function (1D) formula:

G(x) = \frac{1}{\sqrt{2 \pi \sigma^2}} \, e^{-\frac{x^2}{2 \sigma^2}}

2D Gaussian function (used for images):

G(x,y) = \frac{1}{2 \pi \sigma^2} \, e^{-\frac{x^2 + y^2}{2 \sigma^2}}

Where \sigma controls the spread of the Gaussian (larger \sigma → more blurring).

Purpose of Gaussian filtering:

  • Reduces random noise in images.
  • Smooths images while preserving edges better than a simple average filter.
  • Acts as a preprocessing step for edge detection algorithms like Sobel or Canny.
  • Helps in scale-space analysis in computer vision.

9. What are some commonly used image enhancement techniques?

Image enhancement involves improving the visual appearance of an image or making it easier to analyze. The goal is to highlight important features, improve contrast, reduce noise and make details more visible.

1. Contrast Enhancement

  • Improves the difference between dark and bright regions.
  • Makes features more distinguishable in an image.
  • Example: Histogram equalization redistributes pixel intensities for better contrast.

2. Brightness Adjustment

  • Modifies the overall lightness of the image.
  • Achieved by adding or subtracting constant values to pixel intensities.
  • Helps in making dark images clearer or reducing overexposure.

3. Smoothing (Noise Reduction)

  • Reduces unwanted noise in an image while preserving structures.
  • Useful for pre-processing before edge detection or segmentation.
  • Examples: Mean (average) filter, Gaussian filter, Median filter.

4. Sharpening

  • Enhances edges and fine details in an image.
  • Makes features clearer and more defined.
  • Examples: Laplacian filter, Unsharp masking.

5. Edge Enhancement

  • Highlights boundaries between objects or regions in an image.
  • Helps in feature extraction and object detection.
  • Often used in combination with edge detection algorithms like Sobel or Canny.

6. Histogram Processing

  • Adjusts the intensity distribution of an image.
  • Improves visual quality by stretching or equalizing histograms.
  • Examples: Histogram equalization, Histogram stretching.

7. Color Enhancement

  • Improves color balance, saturation or hue.
  • Enhances visual appeal or clarifies features in colored images.
  • Used in photography, medical imaging and remote sensing.

8. Frequency Domain Enhancement

  • Applies filters in the frequency domain to improve image quality.
  • Can remove noise or enhance details based on frequency components.
  • Examples: High-pass filtering for edges, Low-pass filtering for noise reduction.

10. What is histogram equalization and how does it enhance images?

Histogram equalization is an image enhancement technique that improves the contrast of an image by redistributing its intensity values. It spreads out the most frequent intensity values across the entire range, making dark regions brighter and bright regions darker when necessary. T

  • Works by transforming pixel intensities based on the cumulative distribution function (CDF) of the histogram.
  • Enhances global contrast of the image without changing its spatial information.
  • Particularly effective for images where the histogram is concentrated in a narrow intensity range.
  • Can be applied to grayscale images or each channel separately in color images.
  • Variants like Adaptive Histogram Equalization (AHE) or CLAHE work locally to avoid over-enhancement.
  • Improves visibility of details and features in underexposed or low-contrast regions.

11. Explain the concept of color correction and its applications.

Color correction is an image enhancement technique that adjusts the colors of an image to make them appear more natural, accurate or visually appealing. It is used to compensate for lighting conditions, sensor limitations or color casts caused by environmental factors.

  • Adjusts color balance, saturation and hue to correct visual inconsistencies.
  • Compensates for color casts caused by lighting conditions, e.g., tungsten or fluorescent lighting.
  • Ensures that colors are represented accurately for human perception or machine analysis.
  • Can be applied globally to the whole image or locally to specific regions.
  • Widely used in photography, cinematography, broadcasting and image preprocessing for computer vision.
  • Techniques include white balance adjustment, gamma correction and color grading.
  • Improves visual appeal and ensures consistency across multiple images or frames.

12. What is image thresholding, and how does Otsu's method work?

Thresholding converts a grayscale image into a binary image by classifying each pixel as foreground or background based on its intensity relative to a threshold value T: pixels above T become white (255), pixels below become black (0).

  • Global thresholding: Uses one fixed threshold for the whole image.
  • Adaptive thresholding: Computes a different threshold for different regions, useful under uneven lighting.
  • Otsu's method: An automatic global thresholding technique that picks the threshold which minimizes intra-class variance between the foreground and background.
  • Works best on images with a clear bimodal histogram (two distinct peaks for foreground/background).
  • Commonly used before contour detection, OCR preprocessing and simple object segmentation.

13. What are the different types of noise that can occur in images?

Noise in images refers to unwanted random variations in pixel intensity which can degrade image quality and affect analysis. Noise can be introduced during image acquisition, transmission or compression. Different types of noise have distinct characteristics and require different filtering techniques for removal.

1. Gaussian Noise

  • Random variations in intensity following a Gaussian (normal) distribution.
  • Appears as grainy texture, especially in low-light images.
  • Common in sensor readings and electronic imaging devices.

2. Salt-and-Pepper Noise

  • Random occurrences of black and white pixels in an image.
  • Also called impulse noise.
  • Often caused by transmission errors or faulty sensors.

3. Speckle Noise

  • Multiplicative noise that appears as granular interference.
  • Common in radar, ultrasound and coherent imaging systems.

4. Poisson Noise

  • Noise whose variance is proportional to the signal intensity.
  • Arises from photon counting in imaging sensors.
  • Often seen in low-light imaging conditions.

5. Quantization Noise

  • Caused by rounding errors during analog-to-digital conversion.
  • Introduces small fluctuations in intensity values.

6. Periodic Noise

  • Appears as repetitive patterns or lines in an image.
  • Often caused by electrical interference or mechanical vibrations during acquisition.
  • Noise reduction methods depend on the type of noise present.
  • Linear filters like Gaussian blur work well for Gaussian noise.

14. Explain different noise reduction techniques.

Noise reduction techniques are used to remove unwanted variations in pixel intensity while preserving important image details like edges and textures. Different filters are effective for different types of noise.

1. Gaussian Filter

  • A linear smoothing filter that reduces random noise using a weighted average of neighboring pixels.
  • Gives more weight to pixels near the center and less to distant pixels.
  • Effective for Gaussian noise but can blur edges.
  • Kernel size and standard deviation (\sigma) control the amount of smoothing.

2. Median Filter

  • A non-linear filter that replaces each pixel with the median of its neighbors.
  • Very effective for removing salt-and-pepper noise.
  • Preserves edges better than linear smoothing filters.
  • Can be applied with different neighborhood sizes (e.g., 3×3, 5×5).

3. Bilateral Filter

  • Non-linear filter that smooths images while preserving edges.
  • Considers both spatial proximity and intensity similarity for weighting neighboring pixels.
  • Reduces noise without blurring edges.
  • Computationally more intensive than Gaussian or median filters.

4. Non-Local Means (NLM) Filter

  • Excellent at preserving textures and fine details.
  • More computationally expensive than local filters.
  • Gaussian filter is simple and fast but may blur edges.
  • Median filter is ideal for impulsive noise like salt-and-pepper.

15. What is Principal Component Analysis (PCA) and how is it used in image processing?

Principal Component Analysis (PCA) is a dimensionality reduction technique that transforms high-dimensional data into a lower-dimensional space while retaining most of the important information. In image processing, It is often used to reduce the number of features or pixels, compress images, remove redundancy and extract the most significant patterns.

  • PCA identifies the directions (principal components) where the data varies the most.
  • Reduces the size of image data without losing significant information.
  • Helps in removing noise and redundant information from images.
  • Commonly used in face recognition to create eigenfaces.
  • Can be applied to both grayscale and color images by reshaping them into vectors.

16. What are Affine Transformations in images?

Affine transformations are geometric transformations that preserve points, straight lines and parallelism in an image. They are used to rotate, scale, translate, shear or reflect images while maintaining the general structure. They can be represented using matrix multiplication and vector addition, making them computationally efficient for image processing tasks.

  • Affine transformations preserve collinearity and ratios of distances along a line.
  • Common operations include translation, rotation, scaling, reflection and shearing.
  • The transformation of a point (x,y) can be represented as:

\begin{bmatrix} x' \\ y' \end{bmatrix} =\begin{bmatrix} a & b \\ c & d \end{bmatrix}\begin{bmatrix} x \\ y \end{bmatrix} +\begin{bmatrix} t_x \\ t_y \end{bmatrix}

Where (x', y') is the transformed point, a, b, c, d define rotation, scaling or shearing and t_x, t_y define translation.

17. What are geometric transformations in image processing?

Geometric transformations are operations that change the spatial arrangement of pixels in an image. These transformations are used to resize, rotate, translate, warp or map images to a different coordinate system. They are essential for tasks like image registration, object alignment, perspective correction and image stitching.

  • Transformations alter pixel positions while possibly keeping intensity values unchanged.
  • Common types include translation, rotation, scaling, reflection, shearing and affine transformations.
  • Non-linear transformations include perspective (projective) and warping transformations.
  • Can be represented using matrices for linear transformations:

\begin{bmatrix} x' \\ y' \end{bmatrix} =\mathbf{T} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}

Where T is transformation matrix and (x,y),(x',y') are original and transformed coordinates.

  • Geometric transformations are used in image registration, rectification and correcting distortions.
  • Essential in computer vision applications like object tracking, augmented reality and robotic vision.
  • Can be applied to both grayscale and color images.

18. What is a homography, and where is it used?

A homography is a 3×3 matrix that describes a projective transformation mapping points from one plane to another for example, mapping a photographed document to a top-down view, or aligning two images of the same flat scene taken from different camera positions.

  • Maps a point (x, y) in homogeneous coordinates to (x', y') via H: [x' y' w']áĩ€ = H · [x y 1]áĩ€.
  • Typically estimated from at least 4 corresponding point pairs between two images (often using RANSAC to reject outlier matches).
  • Applications: panorama/image stitching, perspective correction (document scanning), augmented reality marker tracking, and mapping camera view to a bird's-eye view in autonomous driving.

19. What are camera intrinsic and extrinsic parameters, and why is camera calibration needed?

Camera calibration is the process of estimating the parameters that describe how a camera maps 3D world points to 2D image points. This is required for tasks that need accurate real-world measurements from images, such as 3D reconstruction, stereo vision, robotics and augmented reality.

  • Intrinsic parameters describe the camera's internal geometry: focal length, optical center (principal point) and lens distortion coefficients. They form the camera matrix K and are fixed for a given camera/lens combination.
  • Extrinsic parameters describe the camera's position and orientation in the world: a rotation matrix R and translation vector t that map world coordinates into the camera's coordinate frame.
  • Calibration is usually performed by capturing multiple images of a known pattern (e.g., a checkerboard) from different angles.
  • Removing lens distortion using the calibration result is a common preprocessing step before geometric analysis.

20. What is epipolar geometry, and how is it used in stereo vision?

Epipolar geometry describes the geometric relationship between two camera views of the same 3D scene. Given a point in one image, epipolar geometry constrains where its corresponding point can lie in the other image along a line called the epipolar line rather than anywhere in the 2D image.

  • The relationship between two calibrated cameras is captured by the essential matrix or the fundamental matrix.
  • In stereo vision, once cameras are rectified , matching a pixel in the left image only requires a 1D search along the same row in the right image.
  • The horizontal pixel shift between matched points is called disparity; disparity is inversely proportional to depth.
  • Used in depth estimation, 3D reconstruction, robot navigation and autonomous driving.

21. What are morphological operations and why are they useful?

Morphological operations are image processing techniques that focus on the shape and structure of objects within an image. They analyze and process images using a small shape called a structuring element to probe and transform the objects.

Uses of Morphological Operations:

  • Removes small noise from binary images using opening operations.
  • Fills small holes or gaps in objects using closing operations.
  • Highlights object boundaries using the morphological gradient.
  • Shrinks or enlarges objects with erosion and dilation, respectively.
  • Helps in feature extraction and preparing images for segmentation.
  • Useful for preprocessing images in computer vision and pattern recognition tasks.

22. What is the morphological gradient?

The morphological gradient is a morphological operation that highlights the edges or boundaries of objects in an image. It is computed as the difference between the dilation and erosion of an image using a structuring element.

Uses of Morphological Gradient:

  • Highlights object boundaries clearly in images.
  • Useful for edge detection in pre-processing steps.
  • Helps in segmentation by identifying contours of objects.
  • Enhances structural details without significantly altering object shapes.
  • Can be combined with other morphological operations for feature extraction.
  • Formula:

Gradient = Dilation(f) - Erosion(f)

Where f is the input image.

23. What is an edge in an image?

An edge in an image is a boundary or transition between regions with significant changes in intensity or color. Edges correspond to object boundaries, surface markings or texture changes. Detecting edges is a fundamental step in image processing because it helps identify important structures and shapes within the image.

  • Appears where intensity changes sharply.
  • Represents boundaries between objects or regions.
  • Can be detected using gradient-based or morphological techniques.

24. Explain Sobel and Prewitt edge detectors.

1. Sobel operator: It is a gradient-based edge detection method that detects edges in both horizontal and vertical directions. It uses two 3×3 convolution kernels to compute approximate derivatives along x and y axes. The final edge strength is obtained by combining these gradients.

  • Horizontal kernel detects vertical edges; vertical kernel detects horizontal edges.
  • Gradient magnitude:

G = \sqrt{G_x^2 + G_y^2}

Where G_x and G_y are convolutions of the image with the Sobel kernels.

2. Prewitt Edge Detectors: The Prewitt operator is another gradient-based edge detection method similar to Sobel but uses simpler averaging in the kernels. It also uses two 3×3 kernels to detect horizontal and vertical edges.

  • Gradient magnitude:

G = \sqrt{G_x^2 + G_y^2}

  • Less robust to noise compared to Sobel.
  • Faster and simpler to compute.

25. Explain the Canny edge detection algorithm step by step.

The Canny edge detector is a multi-step gradient-based edge detection method designed to detect edges in images accurately and with minimal noise. It combines smoothing, gradient calculation, non-maximum suppression and edge tracking to produce clean edge maps.

Steps in the Canny Algorithm:

Step 1: Noise Reduction

  • Smooth the image using a Gaussian filter to reduce noise.
  • Kernel size and standard deviation (\sigma) control smoothing.

I_s = I * G_\sigma

Where I is the input image and G_\sigma​ is the Gaussian kernel.

Step 2: Gradient Calculation

  • Compute gradients in the x and y directions using Sobel operators.
  • Calculate gradient magnitude and direction:

Step 3: Non-Maximum Suppression

  • Thins the edges by keeping only local maxima in the gradient direction.
  • Suppresses pixels that are not on the edge ridge.

Step 4: Double Thresholding

  • Apply two thresholds: high and low.
  • Classify edges as strong, weak or non-edges based on these thresholds.

Step 5: Edge Tracking by Hysteresis

  • Connect weak edges to strong edges if they are connected, otherwise discard them.
  • Produces the final clean edge map.

Combines noise reduction, edge detection and thresholding for accurate edge extraction.

26. Explain the Hough Transform and its use in detecting lines and circles.

The Hough Transform is a feature extraction technique used to detect parametric shapes most commonly straight lines and circles even when they are broken up by noise or partial occlusion. Rather than operating directly on pixel coordinates, it transforms the problem into a "voting" process in parameter space.

  • Line detection: A line can be parameterized as ρ = x·cosÎļ + y·sinÎļ. Every edge pixel votes for all (ρ, Îļ) combinations of lines that could pass through it.
  • Circle detection (Hough Circle Transform): Extends the same voting idea to a 3-parameter space (center x, center y, radius r).
  • Typically applied to an edge map (e.g., output of Canny) rather than the raw image.
  • Robust to noise and partial occlusion since it aggregates votes across many pixels rather than relying on any single point.
  • Applications: lane detection in autonomous driving, detecting circular objects (coins, cells, pupils), document/table structure detection.

27. What is the Harris Corner Detector, and how does it differ from the FAST detector?

Corner detection finds keypoints locations where the image intensity changes sharply in multiple directions that are stable and repeatable across viewing conditions, making them good candidates for tracking and matching.

  • Harris Corner Detector: Examines local intensity changes by computing a structure tensor from image gradients in a local window. It is rotation-invariant but not scale-invariant and is relatively slow due to per-pixel matrix computation.
  • FAST (Features from Accelerated Segment Test): A much faster corner detector that examines a circle of 16 pixels around a candidate pixel and classifies it as a corner if a contiguous arc of pixels is consistently brighter or darker than the center pixel by a threshold.
  • FAST is commonly paired with a descriptor like BRIEF (as in ORB) to build a complete, fast keypoint detection-and-description pipeline for real-time tracking and SLAM.

28. What is a feature descriptor in computer vision?

A feature descriptor is a representation of an image region or keypoint that captures distinctive information about its appearance, shape or texture. Feature descriptors are used to describe and match keypoints across images, enabling tasks like object recognition, image matching and tracking.

  • Encodes information about local image patterns, such as edges, corners or textures.
  • Examples of feature descriptors: SIFT, SURF, ORB, BRIEF, HOG.
  • Usually represented as a vector of numbers that summarizes the local region around a keypoint.
  • Enables feature matching between images for applications like panorama stitching or 3D reconstruction.
  • Can be invariant to scale, rotation and illumination depending on the descriptor type.
  • Often used in combination with feature detectors (e.g., Harris corner, FAST) to find and describe keypoints.

29. What is Scale-Invariant Feature Transform (SIFT) and how does it work?

Scale-Invariant Feature Transform (SIFT) is a feature detection and description method used in computer vision to identify and describe distinctive keypoints in images. It is invariant to scale, rotation and partially invariant to illumination changes, making it ideal for matching objects across images taken from different viewpoints or under different conditions.

Step 1: Scale-space Extrema Detection: Identify potential keypoints by searching for local maxima and minima in the Difference of Gaussian (DoG) images at multiple scales.

Step 2: Keypoint Localization: Refine keypoints by eliminating unstable points with low contrast or poorly defined edges.

Step 3: Orientation Assignment: Assign a dominant orientation to each keypoint based on local gradient directions, making descriptors rotation-invariant.

Step 4: Keypoint Descriptor Generation:

  • Compute a 128-dimensional vector based on the gradient magnitudes and orientations around the keypoint.
  • The descriptor captures local appearance patterns robustly.

30. Explain Speeded Up Robust Features (SURF).

Speeded Up Robust Features (SURF) is a fast and robust feature detection and description algorithm in computer vision. It is designed as a computationally efficient alternative to SIFT, providing scale- and rotation-invariant keypoints and descriptors for tasks like image matching, object recognition and tracking.

  • Detects keypoints using a Hessian matrix-based detector and assigns a dominant orientation for rotation invariance.
  • Uses integral images to speed up computation and creates 64- or 128-dimensional descriptors based on local Haar wavelet responses.
  • Faster than SIFT while remaining robust to scale, rotation and illumination changes.

31. What is ORB and how does it compare to SIFT and SURF?

ORB (Oriented FAST and Rotated BRIEF), SIFT (Scale-Invariant Feature Transform), and SURF (Speeded-Up Robust Features) are feature detection and description algorithms used in computer vision.

ORB (Oriented FAST and Rotated BRIEF)

  • ORB combines the FAST keypoint detector with the BRIEF descriptor.
  • It is rotation-invariant and partially scale-invariant.
  • It uses binary descriptors, making feature matching very fast.
  • It is computationally efficient and suitable for real-time applications.
  • It is widely used in SLAM, object tracking, augmented reality, and mobile vision systems.
  • Goal: Detect and describe features efficiently for real-time computer vision.

SIFT (Scale-Invariant Feature Transform)

  • SIFT detects distinctive keypoints using the Difference of Gaussians (DoG) method.
  • It is invariant to scale, rotation, and moderate illumination changes.
  • It generates highly distinctive floating-point descriptors.
  • It is more accurate but computationally slower than ORB.
  • It is commonly used in image stitching, object recognition, and image matching.
  • Goal: Detect highly robust feature points.

32. What is the Histogram of Oriented Gradients (HOG) and how is it used?

Histogram of Oriented Gradients (HOG) is a feature descriptor used in computer vision to represent the local shape and appearance of objects in an image. It works by dividing the image into small cells, computing the gradient orientation in each cell and forming histograms of these orientations.

  • Divides the image into small spatial regions (cells).
  • Computes gradients (magnitude and direction) at each pixel.
  • Forms histograms of gradient orientations for each cell.
  • Groups cells into blocks for normalization to improve robustness to illumination.
  • Produces a feature vector representing local shapes and textures.
  • Widely used in pedestrian detection, object recognition and image classification.

33. Explain template matching and its limitations.

Template matching is a technique in computer vision used to find parts of an image that match a given template or reference pattern. It works by sliding the template over the input image and computing a similarity measure (e.g., cross-correlation) at each position. The location with the highest similarity indicates the best match.

  • Computes similarity metrics such as sum of squared differences (SSD), cross-correlation or normalized correlation between template and image regions.
  • Can be applied in grayscale or color images.
  • Works best for rigid objects with little variation in scale, rotation or lighting.
  • Can detect single or multiple occurrences of the template in an image.

Limitations:

  • Sensitive to scale changes—template size must match object size.
  • Sensitive to rotation and orientation changes.
  • Sensitive to illumination and contrast variations.
  • Computationally expensive for large images or multiple templates.
  • Cannot handle non-rigid or highly deformable objects effectively.

34. What is optical flow? Explain Lucas-Kanade method.

Optical flow is a technique in computer vision that estimates the motion of objects, surfaces or edges between consecutive frames in a video. It represents the apparent motion of pixels as a vector field, showing the direction and magnitude of movement.

  • Represents motion as a velocity vector for each pixel: \mathbf{v} = (u, v) where u and v are horizontal and vertical displacements.
  • Assumes brightness constancy, i.e., pixel intensity remains constant between frames.
  • Can be dense (every pixel) or sparse (selected Keypoints).

Lucas-Kanade Method: The Lucas-Kanade method is a sparse optical flow algorithm that estimates motion for a set of keypoints by assuming small motion and constant velocity within a local neighborhood. It solves a set of linear equations for each keypoint to compute the displacement vectors.

  • Uses a small window around each keypoint to approximate motion.
  • Solves the optical flow equation using least squares minimization:

I_x u + I_y v = -I_t

Where I_x, I_y ​ are spatial derivatives, I_t is temporal derivative and (u,v) is the flow vector.

  • Works well for small, local motions and is computationally efficient.
  • Often combined with pyramidal implementation to handle larger motions.
  • Used in object tracking, motion estimation and video stabilization.

35. What is object tracking, and how do algorithms like Kalman Filter, SORT and DeepSORT work?

Object tracking maintains a consistent identity for one or more objects across video frames, as opposed to detection, which only locates objects in a single frame. A tracker typically predicts where an object will be next, then associates new detections with existing tracks.

  • Kalman Filter: A recursive algorithm that predicts an object's next state from its motion model, then corrects that prediction using the newly observed detection.
  • SORT (Simple Online and Realtime Tracking): Combines a Kalman filter with the Hungarian algorithm. Very fast, but can lose track identity during occlusion since it uses no appearance information.
  • DeepSORT: Extends SORT by adding a deep-learning appearance descriptor for each tracked object, so that association considers both motion and visual similarity.
  • Applications: surveillance, autonomous driving, sports analytics, pedestrian tracking.

36. What is the Watershed algorithm, and how is it used for image segmentation?

The Watershed algorithm treats a grayscale image as a topographic surface, where pixel intensity represents elevation. It "floods" this surface from local minima , and builds "dams" wherever water from different basins would merge those dam lines become the segmentation boundaries.

  • Works well for separating touching or overlapping objects that simple thresholding cannot split (e.g., adjacent cells in a microscopy image).
  • Applied directly on raw images, it tends to over-segment due to noise, so it's usually run on a distance transform or with markers (marker-controlled watershed) to constrain flooding to meaningful regions.
  • Common pipeline: threshold → distance transform → identify sure foreground/background → mark unknown regions → apply watershed.
  • Applications: cell/nuclei segmentation in medical imaging, separating overlapping coins/objects in industrial inspection.

37. How can image segmentation be performed using K-Means clustering?

K-Means clustering can segment an image by grouping pixels with similar features (like color or intensity) into clusters. Each cluster corresponds to a segment in the image. Here are the proper steps to perform image segmentation using K-Means:

1. Feature Representation:

  • Represent each pixel as a feature vector.
  • Commonly, use RGB values or grayscale intensity, optionally including spatial coordinates to consider location.

2. Initialize Clusters:

  • Choose the number of clusters, K, representing the desired segments.
  • Randomly initialize K centroids in the feature space.

3. Assign Pixels to Clusters:

  • For each pixel, compute the distance (e.g., Euclidean) to each centroid.
  • Assign the pixel to the nearest centroid, forming K clusters.

4. Update Centroids:

  • Compute the new centroid of each cluster as the mean of all assigned pixels.

5. Iterate Until Convergence:

  • Repeat the assignment and update steps until centroids do not change significantly or a maximum number of iterations is reached.

6. Generate Segmented Image:

  • Replace each pixel’s value with the centroid value of its cluster or assign a unique color to each cluster.

7. Post-processing:

  • Apply smoothing or morphological operations to refine segment boundaries.

38. What are the commonly used activation functions in CNNs?

An activation function introduces non-linearity into a neural network, letting it learn complex, non-linear mappings between input and output rather than being restricted to linear combinations of features.

  • ReLU (Rectified Linear Unit): f(x) = max(0, x). The default choice in most CNNs fast to compute and helps mitigate vanishing gradients, but can suffer from "dying ReLU" where neurons output zero permanently.
  • Leaky ReLU: f(x) = x if x > 0, else Îąx (small Îą like 0.01). Allows a small gradient for negative inputs, fixing the dying ReLU problem.
  • Sigmoid: f(x) = 1/(1+eâŧËĢ). Squashes output to (0,1); used in binary classification output layers, but saturates and causes vanishing gradients in deep networks.
  • Tanh: Similar to sigmoid but outputs in (-1,1), zero-centered, still suffers from saturation.
  • Softmax: Converts a vector of raw scores (logits) into a probability distribution over classes; used in the output layer of multi-class classifiers.

39. How does a Convolutional Neural Network (CNN) work for image classification?

A Convolutional Neural Network (CNN) is a deep learning model that automatically learns important features from images for classification. It works by processing the image through multiple layers that detect patterns at different levels, from simple edges in early layers to complex shapes in deeper layers and finally outputs probabilities for each class.

  • Convolutional Layers: Apply filters to detect local features like edges or textures.
  • Activation Functions: Add non-linearity, e.g., ReLU.
  • Pooling Layers: Reduce spatial dimensions and computation while retaining important features.
  • Fully Connected + Softmax Layers: Flatten feature maps and output class probabilities.

40. What are convolutional layers, pooling layers and fully connected layers?

Convolutional Layers, Pooling Layers, and Fully Connected (FC) Layers are the main building blocks of a Convolutional Neural Network (CNN).

1. Convolutional Layer

  • The convolutional layer applies filters (kernels) to the input image to extract features such as edges, textures, and shapes.
  • Each filter produces a feature map that highlights specific patterns.
  • Early layers learn simple features (edges and corners), while deeper layers learn complex features (objects and faces).
  • It significantly reduces the number of learnable parameters compared to fully connected layers.

2. Pooling Layer

  • The pooling layer reduces the height and width of feature maps.
  • It retains the most important information while reducing computation and memory usage.
  • It helps reduce overfitting and improves translation invariance.
  • Common types are Max Pooling and Average Pooling.

3. Fully Connected (FC) Layer

  • The fully connected layer connects every neuron from the previous layer to every neuron in the current layer.
  • It combines the extracted features to make the final prediction.
  • It is usually placed at the end of the CNN.
  • For classification tasks, the final layer often uses Softmax (multi-class) or Sigmoid (binary classification).

41. What is the purpose of pooling layers in CNNs?

Pooling layers reduce the spatial dimensions of feature maps while retaining the most important information, helping the network focus on dominant features rather than precise pixel locations.

  • Dimensionality Reduction: Reduces the size of feature maps, lowering computation and memory usage.
  • Translation Invariance: Makes the network less sensitive to small shifts or distortions in the input.
  • Feature Emphasis: Highlights the most significant activations (e.g., using max pooling).
  • Overfitting Control: Simplifies representations which can help prevent overfitting.

42. What is the difference between max pooling and average pooling?

Max Pooling and Average Pooling are downsampling techniques used in Convolutional Neural Networks (CNNs).

Max Pooling

  • Max Pooling selects the largest value from each pooling window.
  • It preserves the most prominent features, such as edges and textures.
  • It is more robust to small translations and noise.
  • It is the most commonly used pooling method in CNNs.
  • Goal: Retain the strongest and most important features.

Average Pooling

  • Average Pooling computes the average value of each pooling window.
  • It preserves the overall information in the feature map.
  • It produces smoother feature maps but may weaken prominent features.
  • It is less commonly used in modern CNN architectures.
  • Goal: Retain the average representation of features.

43. What is Batch Normalization, and why is it used in CNNs?

Batch Normalization (BatchNorm) is a technique that normalizes the activations of a layer across a mini-batch subtracting the batch mean and dividing by the batch standard deviation then applies a learnable scale (Îģ) and shift (Îē) so the network can still represent the optimal distribution if needed.

  • Reduces "internal covariate shift" the tendency of layer input distributions to change during training as earlier layers' weights update which stabilizes and speeds up training.
  • Allows the use of higher learning rates without the risk of divergence.
  • Acts as a mild regularizer, sometimes reducing (but not replacing) the need for dropout.
  • Typically inserted after the convolution/linear layer and before the activation function.
  • At inference time, it uses running averages of mean/variance computed during training instead of batch statistics, since a single test image doesn't have a "batch."

44. What is dropout in CNNs and why is it used?

Dropout is a regularization technique in Convolutional Neural Networks (CNNs) that helps prevent overfitting by randomly deactivating a fraction of neurons during training.

  • Randomly sets a percentage of neurons’ outputs to zero during training iterations.
  • Helps prevent overfitting by reducing co-adaptation between neurons.
  • Encourages the network to learn robust and distributed features.
  • Usually applied to fully connected layers, but can also be applied to convolutional layers.
  • During testing, all neurons are active and outputs are scaled appropriately to maintain consistency.

45. What is the vanishing/exploding gradient problem, and how do modern architectures address it?

During backpropagation in a deep network, gradients are computed layer by layer using the chain rule, which involves multiplying many partial derivatives together.

  • Vanishing gradients: If these derivatives are consistently small (e.g., from saturating activations like sigmoid/tanh), the accumulated gradient shrinks exponentially as it propagates to earlier layers, so those layers learn extremely slowly or stop learning altogether.
  • Exploding gradients: Conversely, if the derivatives are consistently large, gradients can grow exponentially, causing unstable updates and diverging loss.

46. What are some famous CNN architectures?

Over the years, several CNN architectures have become milestones in deep learning, each introducing innovations that advanced image classification, feature extraction and efficiency.

  • LeNet (1990s): One of the first CNNs, designed for handwritten digit recognition (MNIST). Simple architecture with convolution, pooling and fully connected layers.
  • AlexNet (2012): Popularized deep CNNs for ImageNet classification. Introduced ReLU activations, dropout and data augmentation to reduce overfitting.
  • VGG (2014): Uses very deep networks with uniform 3×3 convolution filters. Emphasizes depth and simplicity for improved feature learning.
  • GoogLeNet / Inception (2014): Introduced Inception modules, combining multiple filter sizes in parallel to capture multi-scale features efficiently.
  • ResNet (2015): Introduced residual connections (skip connections) to train very deep networks without vanishing gradients. Variants include ResNet-50, ResNet-101, ResNet-152.
  • DenseNet (2017): Connects every layer to all subsequent layers, improving feature reuse and gradient flow.
  • MobileNet (2017): Optimized for mobile and embedded devices, uses depthwise separable convolutions to reduce computation.
  • EfficientNet (2019): Scales depth, width and resolution uniformly using compound scaling, achieving high accuracy with fewer parameters.
  • Xception (2017): Extends Inception by using depthwise separable convolutions, improving computational efficiency.

47. Explain the concept of transfer learning in CNNs.

Transfer learning is a technique in Convolutional Neural Networks (CNNs) where a pre-trained model, trained on a large dataset, is reused for a different but related task. Instead of training a CNN from scratch which requires large datasets and high computation, transfer learning uses the features learned by existing models and adapts them to the new task.

  • Uses pre-trained models such as VGG, ResNet or Inception.
  • Can freeze early layers (feature extractors) and retrain later layers for the new task.
  • Helps in small dataset scenarios where training a CNN from scratch is impractical.
  • Commonly applied in image classification, object detection and medical imaging.
  • Allows rapid development of high-accuracy models without large computational resources.

48. How does data augmentation help improve CNN performance?

Data augmentation is a technique used in Convolutional Neural Networks (CNNs) to artificially increase the size and diversity of the training dataset by applying various transformations to the existing images.

  • Common transformations include rotation, flipping, scaling, cropping, translation and brightness adjustments.
  • Helps the network become invariant to orientation, position and scale of objects.
  • Reduces overfitting by preventing the model from memorizing the training data.
  • Simulates real-world variations, improving robustness.
  • Simple to implement using libraries like TensorFlow, Keras and PyTorch.

49. What is Intersection over Union (IoU), and why is it used in object detection?

IoU is a metric that measures how well a predicted bounding box overlaps with the ground-truth bounding box.

IoU = (Area of Overlap) / (Area of Union)

  • IoU ranges from 0 (no overlap) to 1 (perfect overlap).
  • A prediction is typically counted as a "correct" (true positive) detection if its IoU with the ground truth exceeds a chosen threshold (commonly 0.5).
  • Used both as a training signal (e.g., in IoU-based losses like GIoU/DIoU) and as an evaluation criterion for detection accuracy.
  • Also central to Non-Maximum Suppression, where IoU determines which overlapping boxes are considered duplicates of the same object.

50. What is Non-Maximum Suppression (NMS), and why is it needed in object detection?

Object detectors typically generate many overlapping candidate boxes around the same object (from different anchors or grid cells). NMS is a post-processing step that removes redundant boxes, keeping only the most confident detection per object.

  • Without NMS, a single object would produce many overlapping, redundant bounding boxes.
  • Soft-NMS is a variant that decays the score of overlapping boxes instead of removing them outright, which helps in scenes with closely packed, overlapping objects.

Algorithm:

  1. Sort all predicted boxes for a class by confidence score, highest first.
  2. Select the highest-scoring box and add it to the final output list.
  3. Compute IoU between this box and all remaining boxes; remove any box with IoU above a threshold (e.g., 0.5), since it's considered a duplicate detection of the same object.
  4. Repeat with the next highest-scoring remaining box until none are left.

51. How do YOLO and SSD object detection models work?

YOLO (You Only Look Once) and SSD (Single Shot MultiBox Detector) are real-time object detection models that predict object locations and class probabilities in a single forward pass of a CNN, making them fast and efficient for practical applications.

YOLO (You Only Look Once)

  • YOLO divides the input image into a grid and predicts bounding boxes and class probabilities for each grid cell.
  • The network treats detection as a single regression problem, allowing it to simultaneously detect multiple objects while being extremely fast.
  • Variants like YOLOv3, YOLOv4 and YOLOv8 have improved accuracy and speed. YOLO is widely used in real-time applications.

SSD (Single Shot MultiBox Detector)

  • SSD detects objects by applying convolutional filters to multiple feature maps of different scales, allowing it to detect objects of varying sizes.
  • It predicts bounding boxes and class scores for multiple default anchor boxes at each location.
  • SSD balances speed and accuracy, often performing better than YOLO on small object detection and is used in autonomous driving, video surveillance and robotics.

52. Explain Region Proposal Networks (RPN) in Faster R-CNN.

Region Proposal Networks (RPN) are a key component of Faster R-CNN, designed to generate candidate object regions (proposals) efficiently for detection.

  • Slides a small network over the convolutional feature map of the input image.
  • At each spatial location, predicts objectness scores (likelihood of an object) and bounding box coordinates.
  • Uses multiple predefined anchor boxes of different scales and aspect ratios.
  • Proposals are fed to the Fast R-CNN detection head for classification and bounding box refinement.
  • Eliminates the need for separate, computationally expensive region proposal methods.
  • Improves speed and accuracy compared to earlier two-stage detectors.
  • Widely used in object detection tasks where both speed and precision are important.

53. What are anchor boxes, and how are their scales and aspect ratios chosen?

Anchor boxes are a fixed set of reference bounding boxes of predefined scales and aspect ratios, tiled densely across the image at every spatial location.

  • Multiple anchors per location let the network handle objects of varying shapes at the same spatial position.
  • Multi-scale detectors use anchors of different sizes at different feature map resolutions to detect both small and large objects.
  • Anchor scales/ratios are typically chosen based on the size/shape distribution of objects in the training dataset.
  • Each anchor is labeled positive/negative during training based on its IoU with ground-truth boxes, which then drives the classification and box-regression losses.

54. What is mean Average Precision (mAP), and how is it used to evaluate object detection models?

Mean Average Precision (mAP) is one of the most widely used evaluation metrics for object detection models. It measures how accurately a model detects and classifies objects by considering both localization (bounding box accuracy) and classification (correct object class). A higher mAP indicates better overall detection performance.

How mAP is Calculated

  • The model predicts bounding boxes, class labels, and confidence scores.
  • Each predicted bounding box is compared with the ground-truth box using Intersection over Union (IoU).
  • A prediction is considered a True Positive (TP) if:
    1. The predicted class is correct.
    2. The IoU exceeds a predefined threshold (e.g., 0.5).
  • Using TP, False Positives (FP), and False Negatives (FN), a Precision-Recall (PR) curve is generated for each class.
  • The Average Precision (AP) is computed as the area under the Precision-Recall curve for that class.
  • The Mean Average Precision (mAP) is the average of the AP values across all object classes.

55. What is Mask R-CNN and how does it extend Faster R-CNN?

Mask R-CNN is an instance segmentation model that extends Faster R-CNN by adding a mask prediction branch. While Faster R-CNN detects objects and predicts their bounding boxes and class labels, Mask R-CNN additionally generates a pixel-level segmentation mask for each detected object.

Faster R-CNN

  • Faster R-CNN is an object detection model.
  • It uses a Region Proposal Network (RPN) to generate candidate object regions.
  • It predicts Bounding boxes and Class labels
  • t identifies where an object is and what it is.
  • Goal: Detect and classify objects in an image.

Mask R-CNN

  • Mask R-CNN extends Faster R-CNN by adding a parallel mask prediction branch.
  • It predicts Bounding boxes , Class labels and Pixel-wise segmentation masks
  • It replaces RoI Pooling with RoIAlign, which preserves spatial information and improves mask accuracy.
  • It performs instance segmentation, meaning it separates individual object instances even if they belong to the same class.
  • Goal: Detect, classify, and precisely segment each object.

56. What is the difference between semantic segmentation, instance segmentation and panoptic segmentation?

Semantic Segmentation, Instance Segmentation, and Panoptic Segmentation are computer vision tasks that assign labels to image pixels.

Semantic Segmentation

  • Assigns a class label to every pixel in an image.
  • Pixels belonging to the same object category share the same label.
  • It does not distinguish between multiple instances of the same class.
  • Common models include FCN, U-Net, DeepLab, and SegNet.
  • Goal: Classify every pixel into a semantic category.

Instance Segmentation

  • Detects and segments each individual object instance.
  • Objects of the same class receive different masks.
  • Combines object detection with pixel-level segmentation.
  • Common models include Mask R-CNN, YOLACT, and SOLO.
  • Goal: Identify and segment each object separately.

Panoptic Segmentation

  • Combines semantic segmentation and instance segmentation.
  • Assigns a class label to every pixel while also distinguishing individual object instances.
  • Things (countable objects such as people and cars) receive separate instance IDs.
  • Stuff (background regions such as sky, road, and grass) is labeled by semantic class only.
  • Common models include Panoptic FPN, Panoptic-DeepLab, and Mask2Former.
  • Goal: Provide a complete scene understanding by labeling every pixel and identifying individual objects.

57. What are Fully Convolutional Networks (FCNs) for segmentation?

Fully Convolutional Networks (FCNs) are a type of Convolutional Neural Network (CNN) designed specifically for image segmentation. Unlike traditional CNNs used for classification, FCNs replace fully connected layers with convolutional layers, allowing the network to output pixel-level predictions for the entire image.

  • FCNs take an input image of arbitrary size and produce an output of the same spatial dimensions.
  • Use encoder-decoder architecture: the encoder extracts features and the decoder upsamples feature maps to the original resolution.
  • Employ skip connections to combine low-level spatial information with high-level semantic features for precise segmentation.
  • Output is a pixel-wise class probability map which can be converted to a segmented image by selecting the most probable class per pixel.
  • Widely used in semantic segmentation tasks such as road segmentation, medical imaging and object segmentation.

58. What is U-Net, and why is it widely used for biomedical and general image segmentation?

U-Net is a Convolutional Neural Network (CNN) architecture designed for semantic image segmentation. Introduced in 2015 for biomedical image analysis, it predicts a class label for every pixel in an image.

How U-Net Works

  1. Encoder (Contracting Path): Applies convolution and pooling layers to extract features. Gradually reduces the spatial dimensions while increasing feature depth.
  2. Bottleneck: Captures high-level semantic features of the image.
  3. Decoder (Expanding Path): Uses upsampling (or transposed convolution) to restore the original image resolution. Reconstructs the segmentation map.
  4. Skip Connections: Connect corresponding encoder and decoder layers. Preserve fine-grained spatial information lost during downsampling. Improve localization and segmentation accuracy.

Why U-Net is Widely Used

  • Produces pixel-level segmentation with high accuracy.
  • Skip connections preserve fine details and object boundaries.
  • Performs well even with limited training data, especially using data augmentation.
  • Works effectively for both small and large objects.
  • Can be adapted to various image segmentation tasks beyond healthcare.
  • Goal: Generate accurate segmentation masks by combining local and global image features.

59. How is segmentation quality evaluated? Explain the Dice coefficient and IoU for segmentation.

Segmentation models are evaluated by comparing the predicted segmentation mask with the ground-truth mask. The two most commonly used evaluation metrics are the Dice Coefficient (Dice Score) and Intersection over Union (IoU).

Dice Coefficient (Dice Score)

The Dice Coefficient measures the similarity between the predicted mask and the ground-truth mask. It ranges from 0 to 1, where:

  • 1 indicates perfect overlap.
  • 0 indicates no overlap.

Formula:

\text{Dice} = \frac{2|P \cap G|}{|P| + |G|}

Where:

  • P = Predicted mask
  • G = Ground-truth mask
  • Gives more weight to the overlapping region.
  • Particularly useful for medical image segmentation, where the target object may occupy only a small portion of the image.
  • A higher Dice score indicates better segmentation performance.

60. How would you train a CNN on a small dataset?

Training a Convolutional Neural Network (CNN) on a small dataset can be challenging due to the risk of overfitting and insufficient data to learn robust features. To overcome this, several strategies can be applied to improve generalization and performance.

  • Data Augmentation: Artificially increase dataset size by applying rotations, flips, scaling, translations, brightness adjustments, etc., to create diverse training samples.
  • Transfer Learning: Use a pre-trained CNN (like VGG, ResNet or Inception) as a feature extractor and fine-tune its later layers for the small dataset.
  • Regularization Techniques: Apply dropout, weight decay or early stopping to reduce overfitting.
  • Simplify the Network: Use a shallower architecture with fewer parameters to match the dataset size.
  • Cross-Validation: Use k-fold cross-validation to better estimate performance and reduce variance.
  • Batch Normalization: Helps stabilize learning and allows higher learning rates, improving convergence.
  • Learning Rate Scheduling: Adjust learning rates dynamically to avoid overfitting and improve training efficiency.

61. What is a Generative Adversarial Network (GAN)?

A Generative Adversarial Network (GAN) is a type of deep learning model used for generating realistic data, such as images, from random noise. It consists of two neural networks— a generator and a discriminator—competing against each other in a game-theoretic setup.

  • Generator: Creates synthetic data from random noise, aiming to fool the discriminator.
  • Discriminator: Evaluates data and predicts whether it is real or generated.
  • Training is a minimax game where the generator minimizes its loss while the discriminator maximizes its ability to detect fake data.
  • GANs are widely used in image synthesis, style transfer, data augmentation, super-resolution and deepfake generation.

62. How does the generator and discriminator work in a GAN?

A Generative Adversarial Network (GAN) consists of two neural networks—the generator and the discriminator—that compete in an adversarial framework to produce realistic data.

  • Generator: The generator takes random noise as input and produces synthetic data (e.g., images). Its goal is to fool the discriminator into believing that the generated data is real. Over training, the generator learns to capture the underlying data distribution and create increasingly realistic outputs.
  • Discriminator: The discriminator receives both real data from the dataset and fake data from the generator. It outputs a probability indicating whether the input is real or generated. Its goal is to correctly distinguish real data from fake, forcing the generator to improve.

Training Process:

  • The generator and discriminator are trained alternately.
  • The generator minimizes the discriminator’s ability to detect fakes.
  • The discriminator maximizes its accuracy in distinguishing real vs. generated data.
  • This creates a minimax game where the generator improves by producing more realistic data and the discriminator improves by becoming a better detector.

63. What is a DCGAN and how is it different from a vanilla GAN?

A Deep Convolutional Generative Adversarial Network (DCGAN) is an improved version of a Vanilla GAN that replaces fully connected layers with Convolutional Neural Networks (CNNs).

Vanilla GAN

  • Vanilla GAN consists of a Generator and a Discriminator built using fully connected (dense) layers.
  • It generates synthetic data from random noise through adversarial training.
  • It is suitable for simple, low-dimensional datasets.
  • It often struggles to capture spatial features in images.
  • Training can be unstable and may suffer from issues such as mode collapse.
  • Goal: Learn the underlying data distribution and generate realistic samples.

DCGAN

  • DCGAN replaces fully connected layers with convolutional and transposed convolutional layers.
  • The Generator uses transposed convolutions to generate images, while the Discriminator uses convolutions to extract image features.
  • It captures spatial patterns such as edges, textures, and shapes more effectively.
  • It produces higher-quality and more stable image generation than Vanilla GAN.
  • It is widely used for image synthesis, face generation, and image generation tasks.
  • Goal: Generate realistic images by leveraging convolutional neural networks.

64. Explain CycleGAN and its use case.

CycleGAN is a type of Generative Adversarial Network (GAN) designed for unpaired image-to-image translation. Unlike traditional GANs that require paired training data (input-output image pairs), CycleGAN can learn mappings between two domains without direct correspondence, using a cycle-consistency loss to ensure that translating an image to the target domain and back reconstructs the original image.

How it Works:

  • Consists of two generators (A→B and B→A) and two discriminators (one for each domain).
  • Each generator translates images between domains while each discriminator evaluates if the translation is realistic.
  • Cycle-consistency loss ensures that an image translated to the other domain and back is similar to the original.

Use Cases:

  • Style transfer (e.g., turning photographs into paintings).
  • Season translation (e.g., summer to winter landscapes).
  • Domain adaptation (e.g., horses to zebras, day to night images).
  • Medical imaging (e.g., translating MRI scans to CT scans).

65. What are Wasserstein GANs (WGANs) and how do they improve stability?

Wasserstein GANs (WGANs) are a variation of Generative Adversarial Networks designed to improve training stability and convergence. WGANs address these issues by using the Wasserstein distance as a measure of similarity between the real and generated data distributions, instead of the standard Jensen-Shannon divergence used in vanilla GANs.

  • Wasserstein Distance: Provides a smooth and continuous loss even when the distributions of real and fake data do not overlap, giving meaningful gradients to the generator.
  • Critic instead of Discriminator: Replaces the discriminator with a critic network that outputs a real-valued score instead of a probability.
  • Weight Clipping / Gradient Penalty: Enforces the Lipschitz constraint to ensure the Wasserstein distance is valid, improving training stability.
  • Reduces Mode Collapse: Encourages the generator to cover the full data distribution, avoiding collapse to a few outputs.
  • Stable Training: Loss correlates with the quality of generated samples, making it easier to monitor progress.

66. What are Conditional GANs (cGANs) and how do they work?

cGANs extend GANs to allow generation conditioned on additional information (class labels, text or other modalities), instead of generating from random noise alone.

How cGANs Work:

  • The generator receives both a random noise vector and a condition vector (e.g., class label) and generates data that matches the condition.
  • The discriminator receives the generated or real data along with the same condition and predicts whether the data is real or fake while also respecting the condition.
  • Training uses the standard GAN adversarial loss, but conditioned on the additional input.
  • Enables tasks like class-conditioned image generation, text-to-image synthesis and attribute-guided generation.

67. What is a Variational Autoencoder (VAE) and how does it differ from GANs?

A Variational Autoencoder (VAE) is a generative deep learning model that learns a probability distribution (latent space) of the input data and generates new samples by sampling from this distribution.

Variational Autoencoder (VAE)

  • A VAE consists of an Encoder and a Decoder.
  • The Encoder maps the input into a latent probability distribution (mean and variance) instead of a fixed latent vector.
  • The Decoder samples from this latent distribution to reconstruct or generate new data.
  • It is trained using reconstruction loss and KL (Kullback-Leibler) divergence loss.
  • It produces smooth and continuous latent representations, making interpolation between samples possible.
  • Goal: Learn the underlying data distribution and generate new, similar samples.

Generative Adversarial Network (GAN)

  • A GAN consists of a Generator and a Discriminator.
  • The Generator creates synthetic samples from random noise.
  • The Discriminator distinguishes between real and generated samples.
  • Both networks are trained in an adversarial (competitive) manner.
  • GANs typically produce sharper and more realistic outputs than VAEs.
  • Goal: Generate highly realistic synthetic data that is indistinguishable from real data.

68. Explain Denoising Autoencoders (DAEs).

A Denoising Autoencoder (DAE) is a type of autoencoder designed to remove noise from input data. This encourages the network to learn robust and meaningful features rather than merely copying the input.

  • Input data is intentionally corrupted (e.g., with Gaussian noise, masking or salt-and-pepper noise).
  • The encoder maps the noisy input to a latent representation.
  • The decoder reconstructs the clean original data from this representation.
  • Loss function typically measures reconstruction error between the original clean input and the network output.
  • Helps in feature learning, image denoising and pretraining for other deep learning tasks.

69. What is a Convolutional Autoencoder (CAE) and what are its applications?

A Convolutional Autoencoder (CAE) is a type of autoencoder that uses convolutional layers instead of fully connected layers to encode and decode image data. The encoder compresses the input image into a latent feature map and the decoder reconstructs the image from this representation.

Applications:

  • Image Denoising: Removing noise from corrupted images.
  • Dimensionality Reduction: Compressing images while preserving important features.
  • Anomaly Detection: Detecting unusual patterns by measuring reconstruction error.
  • Image Compression: Learning compact representations for storage or transmission.
  • Pretraining for CNNs: Learning feature representations for downstream tasks like classification or segmentation.

70. What are diffusion models, and how do they differ from GANs?

Diffusion Models are a class of generative AI models that generate data by gradually removing noise from random noise through a series of denoising steps.

Diffusion Models

  • Diffusion Models generate data by iteratively denoising random noise.
  • They consist of:
    • Forward Process: Gradually adds noise to training data.
    • Reverse Process: Learns to remove noise step by step to reconstruct the data.
  • They do not require a discriminator.
  • They produce high-quality and diverse outputs.
  • Training is generally more stable than GANs, but inference is slower due to multiple denoising steps.
  • Common examples include DDPM (Denoising Diffusion Probabilistic Models), Stable Diffusion, Imagen, and DALL·E 2.
  • Goal: Learn the data distribution by reversing a noise-adding process to generate realistic samples.

Generative Adversarial Networks (GANs)

  • GANs consist of a Generator and a Discriminator.
  • The Generator creates synthetic data, while the Discriminator distinguishes between real and generated samples.
  • Both networks are trained in an adversarial (competitive) manner.
  • GANs generate images in a single forward pass, making inference fast.
  • Training can be unstable and may suffer from mode collapse, where the Generator produces limited varieties of outputs.
  • Common examples include DCGAN, StyleGAN, CycleGAN, and Pix2Pix.
  • Goal: Generate realistic data by fooling the Discriminator.

71. What is a Vision Transformer (ViT) and how does it work?

A Vision Transformer (ViT) is a deep learning model for image analysis that applies the transformer architecture originally designed for natural language processing, to computer vision tasks. This allows the model to capture long-range dependencies and global context in images effectively.

How ViT Works:

  • Patch Embedding: The input image is divided into fixed-size patches, each flattened and linearly projected into a vector.
  • Position Encoding: Adds positional information to each patch embedding to retain spatial relationships.
  • Transformer Encoder: Uses multi-head self-attention and feed-forward layers to model relationships between patches and extract features.
  • Classification Head: A special [CLS] token summarizes the image representation and is passed through a classifier to predict labels.
  • ViTs require large datasets or pretraining to perform competitively, as they lack the strong inductive bias of CNNs.

72. What is a Swin Transformer and how is it different from a standard ViT?

A Swin Transformer (Shifted Window Transformer) is a hierarchical Vision Transformer architecture designed for computer vision tasks such as image classification, object detection, and image segmentation.

Vision Transformer (ViT)

  • ViT divides an image into fixed-size patches and treats each patch as a token.
  • It applies global self-attention across all image patches.
  • Every patch can attend to every other patch.
  • Computational complexity increases rapidly with image size.
  • It works well for image classification but is less efficient for dense vision tasks.
  • Goal: Learn global relationships among image patches.

Swin Transformer

  • Swin Transformer also divides the image into patches but processes them using local window-based self-attention.
  • It introduces shifted windows, allowing neighboring windows to exchange information across layers.
  • It builds a hierarchical feature representation, similar to CNNs.
  • It is computationally efficient and scales well to high-resolution images.
  • It performs exceptionally well in image classification, object detection, and semantic/instance segmentation.
  • Goal: Learn both local and global image features efficiently.

73. Explain Convolutional Vision Transformer (CvT).

A Convolutional Vision Transformer (CvT) is a hybrid architecture that combines the strengths of Convolutional Neural Networks (CNNs) and Vision Transformers (ViTs). It integrates convolutional layers into the token embedding and attention modules of a transformer, enabling the model to capture local spatial features efficiently while also modeling long-range dependencies through self-attention.

Applications:

  • Image classification and recognition.
  • Object detection and segmentation.
  • Scenarios where local features and global context are both important.

74. What is CLIP and how does it align text and image representations?

CLIP is a multimodal model developed by OpenAI that learns to associate images with natural language descriptions. It jointly trains an image encoder and a text encoder to map both images and corresponding text into a shared embedding space, enabling the model to understand the relationship between visual and textual information.

How CLIP Works:

  • Image Encoder: Processes images (often with a CNN or Vision Transformer) to generate image embeddings.
  • Text Encoder: Processes text (e.g., sentences or captions) using a transformer to generate text embeddings.
  • Contrastive Learning: During training, CLIP maximizes the similarity between matching image-text pairs and minimizes similarity between non-matching pairs.
  • Shared Embedding Space: Both images and text are represented in the same high-dimensional space, allowing comparison using cosine similarity.

Applications:

  • Zero-shot image classification: Classify images without task-specific training.
  • Text-to-image retrieval: Find images matching a textual query.
  • Image captioning and search: Match images to descriptive language.

75. What is ALIGN?

  • ALIGN is a multimodal model developed by Google that, like CLIP, learns to align images and text in a shared embedding space.
  • However, ALIGN is trained on a much larger dataset of noisy image-text pairs collected from the web which allows it to scale to billions of examples and improve robustness.
  • It uses contrastive learning to maximize the similarity of matched image-text pairs while minimizing similarity of mismatched pairs.

76. What is BLIP and what are the differences between CLIP, ALIGN and BLIP?

BLIP (Bootstrapping Language-Image Pre-training), CLIP (Contrastive Language-Image Pre-training), and ALIGN (A Large-scale Image and Noisy-text Embedding) are vision-language models that learn relationships between images and text.

CLIP (Contrastive Language-Image Pre-training)

  • Developed by OpenAI.
  • Trains image and text encoders using contrastive learning.
  • Learns a shared embedding space where matching image-text pairs are close together.
  • Supports zero-shot image classification, image retrieval, and cross-modal search.
  • Goal: Learn aligned image and text representations.

ALIGN (A Large-scale Image and Noisy-text Embedding)

  • Developed by Google.
  • Similar to CLIP but trained on a much larger dataset containing noisy image-text pairs collected from the web.
  • Uses contrastive learning to align image and text embeddings.
  • Improves performance by leveraging large-scale data despite noisy annotations.
  • Goal: Learn scalable image-text representations using massive datasets.

BLIP (Bootstrapping Language-Image Pre-training)

  • Developed by Salesforce Research.
  • Combines contrastive learning with image-text generation objectives.
  • Uses a captioning model to generate cleaner captions during pretraining, improving data quality.
  • Supports both vision-language understanding and vision-language generation tasks.
  • Can perform image captioning, visual question answering (VQA), image-text retrieval, and multimodal reasoning.
  • Goal: Build a unified model for image understanding and text generation.

77. What is self-supervised learning in computer vision? Explain the idea behind contrastive learning methods like SimCLR.

Self-Supervised Learning (SSL) is a learning paradigm in which a model learns useful visual representations from unlabeled data by creating its own supervision (pretext tasks). Contrastive learning, used by methods such as SimCLR, is one of the most popular self-supervised learning approaches.

Self-Supervised Learning (SSL)

  • SSL trains models using unlabeled images.
  • It automatically creates supervision through pretext tasks, eliminating the need for manual labels.
  • The learned representations can later be fine-tuned on downstream tasks with a small amount of labeled data.
  • It significantly reduces the cost of data annotation.
  • Common applications include image classification, object detection, image segmentation, and medical imaging.
  • Goal: Learn meaningful feature representations from unlabeled data.

Contrastive Learning (SimCLR)

  • SimCLR (Simple Framework for Contrastive Learning of Visual Representations) is a self-supervised learning method based on contrastive learning.
  • It creates two different augmented views of the same image using transformations such as cropping, flipping, or color jittering.
  • Both augmented images are passed through the same encoder network.
  • After pretraining, the learned encoder can be fine-tuned for supervised vision tasks.
  • Goal: Learn robust visual representations by maximizing agreement between different views of the same image.

78. Difference between spatial filtering and frequency filtering.

Spatial Filtering and Frequency Filtering are image processing techniques used to enhance or modify images.

Spatial Filtering

  • Spatial Filtering processes the image directly in the spatial (pixel) domain.
  • It applies a kernel (filter/mask) that slides over the image.
  • It is used for smoothing, sharpening, edge detection, and noise removal.
  • Common filters include Mean Filter, Gaussian Filter, Median Filter, Sobel, Prewitt, and Laplacian.
  • It is simpler and computationally efficient for local image processing.
  • Goal: Modify pixel values directly to enhance image quality.

Frequency Filtering

  • Frequency Filtering processes the image in the frequency domain.
  • The image is first transformed using the Fourier Transform (FFT).
  • Filtering is performed by modifying low-frequency or high-frequency components.
  • The filtered image is converted back to the spatial domain using the Inverse Fourier Transform (IFFT).
  • Common filters include Low-Pass Filter, High-Pass Filter, Band-Pass Filter, and Band-Stop Filter.
  • It is useful for removing periodic noise and analyzing image frequency components.
  • Goal: Enhance or suppress specific frequency components.

79. Difference between Linear and Non-Linear Filters.

Linear and Non-Linear Filters are image processing techniques used for noise removal and image enhancement.

Linear Filters

  • Linear filters compute the output pixel as a weighted sum of neighboring pixel values.
  • They preserve linear relationships between pixels.
  • They are effective for reducing Gaussian noise.
  • They may blur edges and fine details.
  • Common examples include Mean Filter, Gaussian Filter, and Laplacian Filter.
  • Goal: Smooth or enhance an image using linear operations.

Non-Linear Filters

  • Non-linear filters compute the output pixel using non-linear operations rather than weighted sums.
  • They are effective at removing impulse (salt-and-pepper) noise.
  • They preserve edges better than linear filters.
  • They are often more computationally expensive.
  • Common examples include Median Filter, Bilateral Filter, Minimum Filter, and Maximum Filter.
  • Goal: Remove noise while preserving important image details such as edges

80. Difference between image sharpening and image smoothing.

Image Sharpening and Image Smoothing are fundamental image enhancement techniques.

Image Sharpening

  • Image Sharpening enhances edges, boundaries, and fine details.
  • It emphasizes high-frequency components in the image.
  • It improves the visual clarity of objects.
  • It may also amplify image noise.
  • Common techniques include Laplacian Filter, Unsharp Masking, High-Pass Filter, and Sobel-based sharpening.
  • Goal: Make important features and edges more prominent.

Image Smoothing

  • Image Smoothing reduces noise and small intensity variations.
  • It suppresses high-frequency components while preserving low-frequency information.
  • It produces a cleaner but slightly blurred image.
  • It is commonly used as a preprocessing step before edge detection or segmentation.
  • Common techniques include Mean Filter, Gaussian Filter, Median Filter, and Bilateral Filter.
  • Goal: Reduce noise and improve image quality.

81. Difference between erosion and dilation.

Erosion and Dilation are fundamental morphological operations used in image processing.

Erosion

  • Erosion shrinks foreground objects by removing boundary pixels.
  • It eliminates small noise and isolated pixels.
  • It can separate objects that are slightly connected.
  • It may remove small details or thin structures.
  • It uses a structuring element (kernel) to determine which pixels to remove.
  • Goal: Remove small objects and refine object boundaries.

Dilation

  • Dilation expands foreground objects by adding pixels to their boundaries.
  • It fills small holes and gaps within objects.
  • It can connect nearby objects that are close together.
  • It increases the size of foreground regions.
  • It also uses a structuring element (kernel) to determine how pixels are added.
  • Goal: Strengthen and enlarge foreground objects.

82. Difference between Sobel, Prewitt and Canny edge detectors.

Sobel, Prewitt, and Canny are edge detection algorithms used in image processing to identify object boundaries. .

Sobel Edge Detector

  • Sobel uses 3 × 3 convolution kernels to compute gradients in the horizontal and vertical directions.
  • It gives slightly more weight to the center pixels, making it more robust to noise than Prewitt.
  • It detects edge direction and edge strength.
  • It is simple and computationally efficient.
  • Goal: Detect edges using image intensity gradients.

Prewitt Edge Detector

  • Prewitt also uses 3 × 3 convolution kernels to compute horizontal and vertical gradients.
  • All kernel values have equal weights.
  • It is simpler but more sensitive to noise than Sobel.
  • It is suitable for basic edge detection tasks.
  • Goal: Estimate image gradients to detect edges.

Canny Edge Detector

  • Canny is a multi-stage edge detection algorithm.
  • It performs:
    1. Gaussian smoothing to reduce noise.
    2. Gradient computation (often using Sobel).
    3. Non-maximum suppression to produce thin edges.
    4. Double thresholding to classify strong and weak edges.
    5. Edge tracking by hysteresis to retain true edges and remove false ones.
  • It produces thin, accurate, and continuous edges.
  • It is more computationally expensive than Sobel and Prewitt.
  • Goal: Detect high-quality edges while minimizing noise and false detections.

83. Difference between Fast R-CNN, Faster R-CNN and Mask R-CNN.

Fast R-CNN, Faster R-CNN, and Mask R-CNN are object detection models from the R-CNN family.

Fast R-CNN

  • Processes the entire image once through a CNN to generate feature maps.
  • Uses Selective Search to generate region proposals.
  • Extracts features for each proposal using RoI Pooling.
  • Predicts bounding boxes and class labels.
  • Faster than the original R-CNN but still limited by the slow Selective Search algorithm.
  • Goal: Improve object detection speed and accuracy over R-CNN.

Faster R-CNN

  • Replaces Selective Search with a Region Proposal Network (RPN).
  • The RPN generates region proposals directly from the feature maps.
  • Uses RoI Pooling to extract fixed-size features.
  • Predicts bounding boxes and class labels.
  • Much faster and more efficient than Fast R-CNN because proposal generation is learned by the network.
  • Goal: Perform accurate and efficient object detection.

Mask R-CNN

  • Extends Faster R-CNN by adding a parallel mask prediction branch.
  • Replaces RoI Pooling with RoIAlign, which preserves spatial information and improves mask quality.
  • Performs instance segmentation in addition to object detection.
  • Goal: Detect, classify, and precisely segment each object.

84. Difference between one-stage and two-stage object detectors.

One-Stage and Two-Stage object detectors are two approaches used for object detection.

One-Stage Object Detectors

  • Perform object localization and classification simultaneously in a single forward pass.
  • Do not have a separate region proposal stage.
  • Faster inference, making them suitable for real-time applications.
  • May be slightly less accurate, especially for detecting small objects.
  • Common models include YOLO, SSD, RetinaNet, and EfficientDet.
  • Goal: Achieve fast object detection with good accuracy.

Two-Stage Object Detectors

  • Perform detection in two stages Generate Region Proposals (candidate object locations) and Classify the proposals and refine their bounding boxes.
  • Generally provide higher detection accuracy.
  • Better at detecting small and overlapping objects.
  • Slower than one-stage detectors due to the additional proposal stage.
  • Common models include Fast R-CNN, Faster R-CNN, and Mask R-CNN.
  • Goal: Achieve high detection accuracy.

85. How would you design a face recognition system from scratch?

Designing a face recognition system involves multiple stages, including data collection, preprocessing, feature extraction and classification. The goal is to accurately identify or verify individuals based on their facial features. Here’s a structured approach:

1. Data Collection

  • Collect a large dataset of face images with sufficient variation in lighting, pose, expression and background.
  • Examples: LFW, VGGFace2, CASIA-WebFace or your custom dataset.

2. Face Detection

  • Detect faces in images to crop and normalize the region of interest.
  • Common methods: Haar Cascades, HOG + SVM or deep learning-based detectors like MTCNN or RetinaFace.

3. Face Alignment and Preprocessing

  • Align faces so that eyes, nose and mouth are in standard positions.
  • Convert images to grayscale or normalize color channels.
  • Resize images to a fixed size (e.g., 112×112 or 224×224).

4. Feature Extraction

Extract a compact representation (embedding) for each face.

Methods:

  • Traditional: PCA (Eigenfaces), LDA (Fisherfaces) or LBPH (Local Binary Patterns Histograms).
  • Deep Learning: CNN-based embeddings (e.g., FaceNet, ArcFace or a custom CNN).

The feature vector should be robust to pose, lighting and expression changes.

5. Feature Matching / Classification

  • Face Verification: Compare embeddings using a distance metric like cosine similarity or Euclidean distance.
  • Face Identification: Use a classifier (SVM, k-NN or softmax) trained on embeddings to predict the person’s identity.

6. Training Considerations

Data Augmentation: Apply rotations, flips, brightness adjustments or random crops to improve generalization.

Loss Functions for Deep Models:

  • Triplet loss (FaceNet)
  • ArcFace / CosFace (improved angular margin-based losses)

7. System Deployment

  • Real-time recognition: Optimize for speed using frameworks like TensorRT or OpenCV DNN.
  • Database management: Store embeddings in a searchable index (e.g., FAISS) for fast retrieval.
  • Thresholding: Define a distance threshold for verification or rejection.

86. If your CNN model is overfitting, what methods would you use to fix it?

Overfitting occurs when a CNN performs well on the training data but poorly on unseen data, meaning it has memorized training features rather than learning general patterns. Several strategies can reduce overfitting:

1. Data Augmentation

  • Increase dataset diversity by applying random rotations, flips, translations, scaling, brightness adjustments or other transformations.
  • Helps the model generalize better by learning invariant features.

2. Regularization Techniques

  • Dropout: Randomly deactivate neurons during training to prevent co-adaptation.
  • Weight decay (L2 regularization): Penalizes large weights to encourage simpler models.
  • Early stopping: Stop training when validation loss stops improving to avoid overfitting.

3. Reduce Model Complexity

  • Use a smaller network with fewer layers or filters.
  • Avoid unnecessarily large CNNs for small datasets.

4. Transfer Learning

  • Use a pretrained CNN and fine-tune only the last few layers.
  • Reduces the risk of overfitting on small datasets.

5. Batch Normalization: Stabilizes learning and allows higher learning rates, indirectly reducing overfitting.

6. Cross-Validation: Use k-fold cross-validation to estimate model performance and detect overfitting.

7. Increase Dataset Size: Collect more data or use synthetic data generation to provide more examples for training.

87. How would you perform tumor segmentation in MRI scans using K-Means clustering? Explain the steps involved and any preprocessing required.

K-Means clustering is an unsupervised method that can segment tumors based on pixel intensity differences in MRI scans.

1. Preprocessing:

  • Noise reduction: Apply Gaussian or median filtering.
  • Intensity normalization: Standardize pixel intensities across scans.
  • ROI extraction: Focus on brain regions to avoid irrelevant areas.

2. Flatten Image:

  • Convert the 2D MRI image into a 1D array of pixel intensities for clustering.

3. Apply K-Means:

  • Choose a suitable number of clusters (K), e.g., 2 or 3 for background, normal tissue and tumor.
  • Run K-Means to assign each pixel to a cluster based on intensity similarity.

4. Reshape Clusters:

  • Convert the 1D cluster labels back into the original image shape.

5. Post-processing:

  • Use morphological operations (opening, closing) to remove small noisy regions.
  • Optionally, select the cluster corresponding to the tumor based on intensity or size criteria.

It will generate a output with a segmented image highlighting the tumor region for further analysis or classification.

Comment

Explore