setgcapixelsize

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 3.8, Creation date: 2017-04-01, Last change: 2025-09-14

sets the current gca to a default pixelsize

Description

This function is helpful if projections should be calculated on pixel level as used in conebeam or ct projections

See Also: getgcapixelsize

Example Illustration

 missing image of setgcapixelsize(siz)

Syntax

ns=setgcapixelsize(siz)

Input Parameter

siz: [ x y], i.e. [c r]

Output Parameter

ns: [x y], i.e. [c r]

Examples


setgcapixelsize([512 512])




Copyright 2017-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, setgcapixelsize, is designed to set the current graphical context (gca) to a specified pixel size. It is particularly useful for applications involving pixel-level projections, such as in cone beam or CT projections.

Input Parameters

Output Results

Algorithm Steps

  1. Check if siz is a scalar. If so, convert it to a vector [siz siz].
  2. Assign s(2) to siz(1) and s(1) to siz(2), effectively swapping the order.
  3. Retrieve the current figure's position using get(gcf,'Position').
  4. Retrieve the current axes' position using get(gca,'Position').
  5. Calculate the number of rows r by dividing s(1) by the height of the axes b(4) and rounding the result.
  6. Calculate the number of columns c by dividing s(2) by the width of the axes b(3) and rounding the result.
  7. Set the figure's position to [a(1) a(2) c r] using set(gcf,'Position',[a(1) a(2) c r]).
  8. Retrieve the updated figure and axes positions again.
  9. Calculate the new width ny as b(3)*a(3) and the new height nx as b(4)*a(4).
  10. Check if the difference between the desired size s and the actual size [nx ny] is greater than 0.5. If so, throw an error indicating the inability to scale the figure to the desired size.
  11. Return the rounded actual size [nx ny] as ns.
Algorithm explaination created using ChatGPT on 2025-08-19 00:17. (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