Syntax
ns=setgcapixelsize(siz)
Input Parameter
Output Parameter
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
- siz: A vector [x y], representing the desired pixel size. If a scalar is provided, it is expanded to [siz siz].
Output Results
- ns: A vector [x y], representing the actual pixel size set.
Algorithm Steps
- Check if
siz
is a scalar. If so, convert it to a vector [siz siz].
- Assign
s(2)
to siz(1)
and s(1)
to siz(2)
, effectively swapping the order.
- Retrieve the current figure's position using
get(gcf,'Position')
.
- Retrieve the current axes' position using
get(gca,'Position')
.
- Calculate the number of rows
r
by dividing s(1)
by the height of the axes b(4)
and rounding the result.
- Calculate the number of columns
c
by dividing s(2)
by the width of the axes b(3)
and rounding the result.
- Set the figure's position to [a(1) a(2) c r] using
set(gcf,'Position',[a(1) a(2) c r])
.
- Retrieve the updated figure and axes positions again.
- Calculate the new width
ny
as b(3)*a(3)
and the new height nx
as b(4)*a(4)
.
- 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.
- 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