计算机视觉代写

The program applies the brush at different scales and orientations to the image, based on the input image’s edge magnitude and orientation. Edge magnitude and orientation should be calculated by:

⚫ converting the colour image to gray level ⚫ blurring the image
⚫ applying the Sobel edge detector.

The input brush is copied:

  • ⚫  to create various versions at S = 5 different sizes, scaled by factors 1/S,2/S,… S/S=1;

    just use the simplest sampling scheme

  • ⚫  each of the scaled brushes is rotated around the centre of the image by regular

    increments through 360°degrees to generate A = 16 orientations.

    Now start painting. The basic process is:

  • ⚫  start with an empty canvas (i.e. a black output image)
  • ⚫  apply strokes to this canvas in a coarse to fine (i.e. large to small) brush order
  • ⚫  for each brush size randomly generate N positions for the strokes in the image, where

    N = P/D, P = number of pixels in image, D = density; apply the brush at each position if
    ➢ it is the right size; the size should be inversely related to edge magnitude, i.e. use

    the smallest brush at the strongest edges, and the largest brush at the weakest edges

➢ applying the brush improves the canvas; i.e. adding that brush stroke makes the canvas more similar to the input image; measure dissimilarity as the summed absolute difference in RGB values of all corresponding pixels in the input and output images.

To make a brush stroke:
⚫ get the brush at the correction orientation (i.e. closest to the edge orientation at that

point in the image)
⚫ compute the mean RGB (red, green, blue) values in the input image at the pixels

specified by the brush stroke mask
⚫ copy the mean RGB values into the canvas at the pixels specified by the brush stroke

mask.

In addition to the final rendered version of the image generate the following intermediate output images:

  • ⚫  the magnitude and orientation computed by the Sobel edge detector (file names: magnitude.pgm, orientation.pgm)
  • ⚫  the full set of rotated and scaled brushes (file names: brush-s-a, where s is the size index and a is the orientation index)
  • ⚫  the strokes that make up the final rendered output, but rendered in separate images for each brush size (file names: intermediate-0.pgm, intermediate-1.pgm, . . . intermediate- 4.pgm)

    In order to gain higher marks you need to add one novel extension or additional feature (such as those suggested here):

    ⚫ consider different strategies for determining the placement of strokes ⚫ use a weighted brush that applies semi-transparent strokes
    ⚫ deal with unpainted areas of the canvas

    Your program should be able to run in the School’s labs.

    Please note: You should write all the code yourself, and not use third-party libraries.

    Learning Outcomes Assessed

1. Understand the technical details of a range of techniques for image manipulation.

Criteria for assessment

Credit will be awarded against the following criteria.
1. 20% -For implementation of colour to gray conversion, image blurring and

computation of Sobel edge detector.
2. 20% -For generation of rotated and scaled brushes.
3. 40% -For synthesis of brush strokes in the canvas at the appropriate location, scale

and orientation, and with the appropriate colour.
4. 20% -For the design and incorporation of other features beyond the basic coursework specification.