# A3-YinChiaYeh

### From CS294-69 Image Manipulation and Computational Photography Fa11

- Name: Yin-Chia Yeh
- Assignment: Assignment_3:_Gradient_Domain/Resizing_and_Warping

## Contents |

## Summary

For this assignment, I traced the the non-photorealistic rendering filter described in [Shop paper] and implemented a matlab version of it.

The program flow is as following

- Read input image and compute its gradient
- Compute the edge measurement described in the paper. I didn't implement this part but adopted the edge detection result released by the authors.
- Construct the least square system as following
- Enhance or attenuate the gradient according to its edge response. Enhance strong or long edges and attenuate otherwise.
- Set data term to original pixel value
- scale above equations by their square root of the weight (so the square error will be w*(error^2) instead of (w*error)^2)

- Solve the least square system by iterative least square solver(lsqr) of matlab
- Reshape the result into images
- Use edge information to enhance strong edges again to create some artistic strokes

## Result

Here I put my result in parallel with the result generated by GradientShop.

### Bird.jpg

**Original Input Image:**

**Filter result:**

Left:My Matlab implementation / Right:GradientShop

**Filter result without robust weighting**

The paper proposed a weighting scheme to reduce the weight of pixels with larger difference between original gradient and target gradient.

The authors claim this scheme can reduce some bad effect such as halo effect.

I put the result without the robust weighting scheme here. You can see there are indeed some halo effects which do not show up in above results (with the robust weighting)

Left:My Matlab implementation / Right:GradientShop

**Final Filter result with Detail Enhancement**

Left:My Matlab implementation / Right:GradientShop

### Butterfly.jpg

**Original Input Image:**

**Final result:**

Left:My Matlab implementation / Right:GradientShop

## Discussion

You can see somehow the result of gradient shop can maintain more details than my implementation. I haven't figured out the root cause yet. One possible reason is parameter tweaking. Though I tried to follow all parameter settings of GradientShop, but it seems using some different image representation other than simple integer so I have to tweak some parameters to get similar (but not identical) result as GradientShop.

On the other hand, once those parameters are tweaked, they seem to be robust so I don't need to change any parameter to apply it to other images (butterfly.jpg in this case)

Another possibility is the difference between the least square solver, but I don't have much information on that.

One more thing to note is that GradientShop applied preprocessing and postprocessing filters to make the output image more beautiful.

For example, the non-photorealistic rendering result has one preprocessing filter to enhance color saturation and one postprocessing filter to add artistic strokes (as mentioned above.)

I am a little bit surprised because these two simple filters make the image much visually plausible, though they actually are not directly related to the main idea of GradientShop paper. Anyway, I still highly appreciate the authors' effort to opensource this powerful tool!

The original result of GradientShop paper (with all preprocessing and postprocessing on):