how do i change the dicom file's brightness and contrast with slider bar in app designer
3 ビュー (過去 30 日間)
古いコメントを表示
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);
colormap(app.UIAxes_2, 'gray');
title(app.UIAxes_2, 'Sagittal');
axis(app.UIAxes_2, 'image');
% update axial mri image
app.UIAxes_1.Visible = 'off';
img1 = imagesc(squeeze(brightnessAdjusted(128, :, :)), 'Parent', app.UIAxes_1);
colormap(app.UIAxes_1, 'gray');
title(app.UIAxes_1, 'Axial');
axis(app.UIAxes_1, 'image');
% update coronal mri image
app.UIAxes_3.Visible = 'off';
img3 = imagesc(squeeze(brightnessAdjusted(:, :, 128)), 'Parent', app.UIAxes_3);
colormap(app.UIAxes_3, 'gray');
title(app.UIAxes_3, 'Coronal');
axis(app.UIAxes_3, 'image');
end
0 件のコメント
回答 (1 件)
Rik
2023 年 5 月 9 日
編集済み: Rik
2023 年 5 月 9 日
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.
2 件のコメント
Rik
2023 年 5 月 9 日
My bad, I wrote caxes instead of caxis, which has now been renamed to clim.
As long as you specify the parent object, calling clim on a uiaxes object works just fine, so you can in fact use it in AppDesigner.
参考
カテゴリ
Help Center および File Exchange で Biomedical Imaging についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!