AdvancedPhotonSource / tike

Repository for ptychography software
http://tike.readthedocs.io
Other
29 stars 15 forks source link

NEW: Functions for complex valued wavefield plotting #221

Closed a4894z closed 2 years ago

a4894z commented 2 years ago

Purpose

Currently, we split a complex valued array into real and imaginary or magnitude and phase for plotting, but for easy and quick at-a-glance plotting of complex valued arrays it can be useful to combine this information into a single image.

In furtherance of this, a pair of utility functions to visualize a complex valued array in a visually compact way in introduced here.

Approach

I add two functions in this pull request.

The first takes a complex valued image and represents the hue as phase, value as magnitude in a HSV colorspace; the saturation is set to one for all image pixels. This is done in the "complexHSV_to_RGB" function. The resulting RGB image of this function can then be used with matplotlib imshow or imsave functions.

The second function "resize_complex_image" uses openCV interpolation to resize an original complex valued to a much larger size (e.g. 128x128 --> 1024x1024) for ease of visual reference; if this is not done then when we use e.g. imsave from matplotlib, the original array size is used to save an image and this smaller array size might be difficult to see without adequate zooming in.

Provide a brief summary of your algorithm(s) here. -->

For the "complexHSV_to_RGB" function, I use a built in HSV to RGB colorspace conversion function that is a part of matplotlib.

For the "resize_complex_image", I use built in 2D interpolation functions that are part of openCV.

Pre-Merge Checklists

Submitter

Reviewer

a4894z commented 2 years ago

I probably didn't do this pull request correctly, we can go over what I screwed up?

carterbox commented 2 years ago

Thanks for your contribution, @a4894z!