Plotting Utilities - leahghartman/GaussBean GitHub Wiki

This section covers all functions in the plotting utilities module (so, all of the code contained in plot_utils.py).

Often when writing the functions throughout this package, I allowed for users to input either image arrays OR image paths. Therefore, in some of the explanations below, you might see the word OPTIONAL next to the inputs "imgar" and "imgpath", but you HAVE to put in one or the other, you can't just put in nothing.

Note: I wouldn't necessarily copy and paste any of the code here, this is simply for explanation purposes. If you want examples of code that will actually run, look in the examples folder under the "Code" tab above.

Contents:


plot_beforeandafter

plot_beforeandafter(before, after, label='', clmap='plasma', fontsize=15)

The function "plot_beforeandafter" returns a plot of an image before and after it has been run through a filter or altered in some way.

Parameters:

  • before : array : The array associated with an image before it has been altered.
  • after : array : The array associated with an image after it has been altered.
  • label (OPTIONAL) : string : A string associated with WHAT is altering the image (could be "Median Filter" for example). This will be added to the title of the plot.
  • clmap (OPTIONAL) : string : The colormap that the user wants to use for the plots. This MUST be a colormap given by the matplotlib package.
  • fontsize (OPTIONAL) : integer : The fontsize used for the title of the plot. The axes labels are automatically formatted based on this number.

Returns:

  • Plot : Shows a plot of before and after an image has been altered.

plot_median

plot_median(mediansize, repeatamount=0, imgpath='', imgar=[], clmap='plasma', fontsize=15)

The function "plot_median" returns a plot of an image before and after a median filter has been run over it a specified number of times.

Parameters:

  • mediansize : integer : The size of the median filter in pixels (generally want this to be small; from 3-10 pixels).
  • repeatamount (OPTIONAL) : integer : The amount of times the user wants the filter to be run over the image.
  • imgpath (OPTIONAL) : string : The path to the image that the user wants the median filter to run over.
  • imgar (OPTIONAL) : array : The image array that the user wants the median filter to run over.
  • clmap (OPTIONAL) : string : The colormap that the user wants to use for the plots. This MUST be a colormap given by the matplotlib package.
  • fontsize (OPTIONAL) : integer : The fontsize used for the title of the plot. The axes labels are automatically formatted based on this number.

Returns:

  • Plot : Shows a plot of before and after a median filter has been run over the image.

plot_lowpass

plot_lowpass(radius, imgpath='', imgar=[], clmap='plasma', fontsize=15)

The function "plot_lowpass" returns a plot of an image before and after a lowpass filter has been run over it once.

Parameters:

  • radius : integer : The radius (in pixels) of the mask used for the low-pass filter.
  • imgpath (OPTIONAL) : string : The path to the image that the user wants the low-pass filter to run over.
  • imgar (OPTIONAL) : array : The image array that the user wants the low-pass filter to run over.
  • clmap (OPTIONAL) : string : The colormap that the user wants to use for the plots. This MUST be a colormap given by the matplotlib package.
  • fontsize (OPTIONAL) : integer : The fontsize used for the title of the plot. The axes labels are automatically formatted based on this number.

Returns:

  • Plot : Shows a plot of before and after a low-pass filter has been run over the image.

plot_medandlow

plot_medandlow(mediansize, radius, repeatamount=0, imgpath='', imgar=[], clmap='plasma', fontsize=15)

The function "plot_medandlow" returns a plot of the original image, the image after ONLY a median filter has been applied, the image after ONLY a low-pass filter has been applied, and the image after BOTH a median filter and low-pass filter have been applied.

Parameters:

  • mediansize : integer : The size of the median filter in pixels (generally want this to be small; from 3-10 pixels).
  • radius : integer : The radius (in pixels) of the mask used for the low-pass filter.
  • repeatamount : integer : The amount of times the user wants the MEDIAN filter to be run over the image.
  • imgpath (OPTIONAL) : string : The path to the image that the user wants the filters to run over.
  • imgar (OPTIONAL) : array : The image array that the user wants the filters to run over.
  • clmap (OPTIONAL) : string : The colormap that the user wants to use for the plots. This MUST be a colormap given by the matplotlib package.
  • fontsize (OPTIONAL) : integer : The fontsize used for the title of the plot. The axes labels are automatically formatted based on this number.

Returns:

  • Plot : Shows a plot of before and after a low-pass filter has been run over the image.

plot_cropped

plot_cropped(xpoint, ypoint, xmargins, ymargins, imgpath='', imgar=[], clmap='plasma', fontsize=15)

The function "plot_cropped" returns a plot of the image before and after it's been cropped.

Parameters:

  • xpoint : integer : x-coordinate of the point at which the crop will be occurring.
  • ypoint : integer : y-coordinate of the point at which the crop will be occurring.
  • xmargins : integer : A number (in pixels) of how far in the x-direction, on either side of the cropping point, the user wants the image to be cropped.
  • ymargins : integer : A number (in pixels) of how far in the y-direction, on either side of the cropping point, the user wants the image to be cropped.
  • imgpath (OPTIONAL) : string : The path to the image that the user wants to crop.
  • imgar (OPTIONAL) : array : The image array that the user wants to crop.

Returns:

  • Plot : Shows a plot of before and after the image has been cropped.

back_sub_plot

back_sub_plot(origpath='', backpath='', origimgar=[], backimgar=[], clmap='plasma', fontsize=15)

The function "back_sub_plot" returns a plot of the image before and after background subtraction.

Parameters:

  • origpath (OPTIONAL) : string : The path of the original image to be used (the image before background subtraction).
  • backpath (OPTIONAL) : string : The path of the background image to be subtracted from the original image.
  • origimgar (OPTIONAL) : array : Rather than an image path, one can use an array instead. This is the array of the original image to be used (before background subtraction).
  • backimgar (OPTIONAL) : array : Rather than an image path, one can use an array instead. This is the array of the image to be subtracted from the original image.
  • clmap (OPTIONAL) : string : The colormap that the user wants to use for the plots. This MUST be a colormap given by the matplotlib package.
  • fontsize (OPTIONAL) : integer : The fontsize used for the title of the plot. The axes labels are automatically formatted based on this number.

Returns:

  • Plot : Shows a plot of before and after the provided background has been subtracted from the original image.

plot_intensity_proj

plot_intensity_proj(imgpath='', imgar=[], clmap='plasma', fontsize=15)

The function "plot_intensity_proj" returns a plot of the image with PROJECTIONS of the intensity on each axis.

Parameters:

  • imgpath (OPTIONAL) : string : The path to the image that the user wants to use.
  • imgar (OPTIONAL) : array : The image array that the user wants to use.

Returns:

  • Plot : Shows a plot of the original image along with projections of the intensity along each axis.

plot_intensity_line

plot_intensity_line(xpixel, ypixel, toavg=0, imgpath='', imgar=[], clmap='plasma', fontsize=15)

The function "plot_intensity_line" returns a plot of the image with LINEOUTS of the intensity on each axis. The location of the lineouts are specified by the user.

Parameters:

  • xpixel : integer : Specifies the pixel at which the Y LINEOUT will be taken.
  • ypixel : integer : Specifies the pixel at which the X LINEOUT will be taken.
  • toavg (OPTIONAL) : integer : Specifies the number of lineouts on EACH SIDE of the original lineout the user wants to create a projection with (so, if "toavg" is equal to 2, for example, one would have the center lineout, plus two lineouts on either side).
  • imgpath (OPTIONAL) : string : The path to the image that the user wants to use.
  • imgar (OPTIONAL) : array : The image array that the user wants to use.
  • clmap (OPTIONAL) : string : The colormap that the user wants to use for the plots. This MUST be a colormap given by the matplotlib package.
  • fontsize (OPTIONAL) : integer : The fontsize used for the title of the plot. The axes labels are automatically formatted based on this number.

Returns:

  • Plot : Shows a plot of the original image along with lineouts of intensity at locations the user specifies.

⚠️ **GitHub.com Fallback** ⚠️