calibration in image analysis

2 Ansichten (letzte 30 Tage)
Chaitanya kumar reddy
Chaitanya kumar reddy am 4 Okt. 2022
Beantwortet: Udit06 am 29 Sep. 2023
find (BW==1);
[m,n]= find (BW==1);
pos = [m';n'];
D = zeros(1,448)
for i = 1:length(m)
i
D(i,:) = [calibrated_data(m(i),n(i),:)]
end
i have used the above code for calibration but the dataset has 398656 elements and it is taking so long to calibrate like more than 1hr. is there any faster way for calibration??
  2 Kommentare
Benjamin Thompson
Benjamin Thompson am 4 Okt. 2022
Can you provide more information about what you are calibrating, and maybe a small sample image? What is the problem?
Chaitanya kumar reddy
Chaitanya kumar reddy am 4 Okt. 2022
clc
clear all
close all
dataset_name = ['20220118_test_Normalbreast_061722_1_left_2022-06-17_19-28-26'];
raw_data_headfile = strcat('D:\HSI_data\', dataset_name, '\capture\', dataset_name, '.hdr');
raw_data_datafile = strcat('D:\HSI_data\', dataset_name, '\capture\', dataset_name, '.raw');
dark_ref_headfile = strcat('D:\HSI_data\', dataset_name, '\capture\DARKREF_', dataset_name, '.hdr');
dark_ref_datafile = strcat('D:\HSI_data\', dataset_name, '\capture\DARKREF_', dataset_name, '.raw');
white_ref_headfile = strcat('D:\HSI_data\', dataset_name, '\capture\WHITEREF_', dataset_name, '.hdr');
white_ref_datafile = strcat('D:\HSI_data\', dataset_name, '\capture\WHITEREF_', dataset_name, '.raw');
raw_info = enviinfo(raw_data_headfile);
raw_data = multibandread(raw_data_datafile,[raw_info.Height, raw_info.Width, raw_info.Bands],...
raw_info.DataType, raw_info.HeaderOffset, raw_info.Interleave, raw_info.ByteOrder);
dark_info = enviinfo(dark_ref_headfile);
dark_data = multibandread(dark_ref_datafile, [dark_info.Height, dark_info.Width, dark_info.Bands],...
dark_info.DataType, dark_info.HeaderOffset, dark_info.Interleave, dark_info.ByteOrder);
dark_data_avg = mean(dark_data, 1);
white_info = enviinfo(white_ref_headfile);
white_data = multibandread(white_ref_datafile, [white_info.Height, white_info.Width, white_info.Bands],...
white_info.DataType, white_info.HeaderOffset, white_info.Interleave, white_info.ByteOrder);
white_data_avg = mean(white_data, 1);
calibrated_data = raw_data;
for i = 1:size(raw_data, 1)
calibrated_data(i, :, :) = (calibrated_data(i, :, :) - dark_data_avg)./ (white_data_avg - dark_data_avg);
end
rice_dot = calibrated_data(238, 460, :);
background_dot = calibrated_data(323, 658, :);
plot(raw_info.Wavelength, rice_dot(:))
hold on
plot(raw_info.Wavelength, background_dot(:))
legend('grape', 'background')
A = imread('D:\HSI_data\20220118_test_Normalbreast_061722_1_left_2022-06-17_19-28-26\20220118_test_Normalbreast_061722_1_left_2022-06-17_19-28-26.png');
imshow(A)
B = rgb2gray(A);
level = graythresh(B);
BW = im2bw(B,level);
find (BW==1);
[m,n]= find (BW==1);
pos = [m';n'];
D = zeros(1,448)
%D = cell([1 2]);
for i = 1:length(m)
D(i,:) = [calibrated_data(m(i),n(i),:)];
end
% E = mean(D);
% plot(raw_info.Wavelength,E)
% figure
% imshow(BW);
%
%
% % D = calibrated_data(70,275,:);
% % E = reshape(D,[1,448]);

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Udit06
Udit06 am 29 Sep. 2023
Hi Chaitanya,
I understand that the code that you have written for calibration is taking a long time to run. You can utilize the following features supported by MATLAB to make your code run faster.
1) Vectorization: Instead of using a loop to iterate over each element, try to use vectorized operations whenever possible. MATLAB is optimized for array operations, and using vectorization can significantly speed up the computation.
2) Parallel Computing: Consider using parallel computing techniques like MATLAB's "parfor" to distribute the workload across multiple workers.
You can refer to the below MathWorks documentations to understand more about vectorization and “parfor” respectively.
I hope this helps.

Kategorien

Mehr zu Signal Generation and Preprocessing finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by