imadjustwhite

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Images
Introduced first in SolidGeometry 5.1, Creation date: 2021-11-27, Last change: 2025-09-15

adjusts the intensity values from both side that

Description

99.8% of the values define the spread
This function is used to create pseudo CT images from a figure projections

See Also: spreadmax

Example Illustration

 missing image of imadjustwhite(IS)

Syntax

IS=imadjustwhite(IS)

Input Parameter

IS: original intensity matrix

Output Parameter

IS: modified intensity matrix




Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, imadjustwhite, is designed to adjust the contrast of an image stack by modifying the white and black levels based on histogram analysis. It is part of the SolidGeometry library and was introduced in version 5.1.

Input Parameters

Output

Algorithm Steps

  1. Calculate the number of elements in the image stack using numel(IS).
  2. Set the maximum number of gray values to 256, which is typical for 8-bit images.
  3. Compute the histogram of the image stack using histcounts with 256 bins.
  4. Normalize the histogram by dividing by the total number of elements.
  5. Identify the histogram bins where the normalized count is greater than 0.001, indicating significant pixel intensity.
  6. Determine the white level by selecting the second-to-last significant bin and adding 2 to its index, ensuring it does not exceed the maximum number of gray values.
  7. Determine the black level by selecting the first significant bin.
  8. Adjust the image stack by setting all pixel values greater than the white level to the white level and all pixel values less than the black level to the black level.
  9. Recalculate the minimum and maximum values of the adjusted image stack using minmaxall.
  10. If no output is requested, display the image stack using SGfigure and VMmontage, applying a grayscale colormap and setting the color limits to the recalculated minimum and maximum values.
Algorithm explaination created using ChatGPT on 2025-08-19 07:05. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21