5 vues (au cours des 30 derniers jours)
mohd akmal masud le 1 Nov 2023
Modifié(e) : akshatsood le 6 Nov 2023
Dear All,
I want to calculate the upper limit window level (ULWL) on my set images (as attached). this is draft command I develop.
clc
clear all
close all
info = dicominfo('spect128x128');
%gp=info.SliceThickness;
spect=(squeeze(spect));%smooth3
map = hsv(256); % Or whatever colormap you want.
rgbspect = ind2rgb(spect, map); % im is a grayscale or indexed image.
a=t/p;
t = sum(sum(sum(rgbspect))); %should be total sum pixel value of for every slice
p = 130*130; %should be represents the amount of pixels in every slice
u = 50 % constant, for better visual characteristic
ULWL =u*a;
But I failed two things:
1) failed to convert the gray image to RGB image
2) Failed to apply the ULWL formula for all slices.
ANYONE CAN HELP ME.
ALL THE REFERENCES AS PICTURE BELOW.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

akshatsood le 6 Nov 2023
Modifié(e) : akshatsood le 6 Nov 2023
I understand that you seek guidance for calculating the ULWL (upper limit window level) for a set of images. As stated in the question, the queries can be summarised as follows
Failed to convert GRAYSCALE image to RGB image
On executing the provided code snippet, I observed that it resulted in the following error being thrown.
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
The error you encountered is caused by the fact that the "ind2rgb" function expects an indexed image of size (m x n), while in the provided code, "spect" has a size of (130 x 130 x 42). To resolve this issue, you can modify the code by reshaping "spect" to a 2D matrix using "spect(:,:)". This adjustment will ensure compatibility with the "ind2rgb" function and resolve the error. Here is the improved line of code
rgbspect = ind2rgb(spect(:,:), map); % spect is a grayscale or indexed image.
Failed to apply ULWL formula for all slices
In the provided code, an error is observed because the variable "a" is computed using the variables "t" and "p" before they are defined. The message reads as follows.
Unrecognized function or variable 't'.
To address this issue, it is important to define the variables "t" and "p" before calculating "a". Here is an improved code snippet that incorporates the necessary modifications
info = dicominfo('spect128x128');
spect=(squeeze(spect)); % smooth3
map = hsv(256); % or whatever colormap you want.
rgbspect = ind2rgb(spect(:,:), map); % spect is a grayscale or indexed image.
t = sum(sum(sum(rgbspect))); % should be total sum pixel value of for every slice
p = 130*130; % should be represents the amount of pixels in every slice
u = 50 % constant, for better visual characteristic
a=t/p;
ULWL =u*a;
I hope this helps.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

R2023b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by