how do i change the dicom file's brightness and contrast with slider bar in app designer
8 views (last 30 days)
I want to change the brightness and contrast with slider bar.
i made button callback function that read the sagittal direction of 256 dicom files and then print coronal, axial, sagittal mri 2d image through axes,
i do the brightness first, but it didnt work and keep erroring.
here is slider bar's callback function:
function SliderValueChanged(app, event)
% take slider value
sliderValue = app.UIKnob.Value;
% change brightness
brightnessAdjusted = imadjust(app.images, [sliderValue/100, 1], );
% update sagittal mri image
app.UIAxes_2.Visible = 'off';
img2 = imagesc(squeeze(brightnessAdjusted(:, 128, :)), 'Parent', app.UIAxes_2);
% update axial mri image
app.UIAxes_1.Visible = 'off';
img1 = imagesc(squeeze(brightnessAdjusted(128, :, :)), 'Parent', app.UIAxes_1);
% update coronal mri image
app.UIAxes_3.Visible = 'off';
img3 = imagesc(squeeze(brightnessAdjusted(:, :, 128)), 'Parent', app.UIAxes_3);
Rik on 9 May 2023
Edited: Rik on 9 May 2023
You should use caxis instead. That way you can adjust brightness and contrast directly without having to redraw the image every time.
If you need inspiration, you can have a look at how I implemented window leveling in this FEX submission. It cannot be directly used in AppDesigner, but seeing the code should help.