이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Can somebody please help me how to convert *.bil files to *.cyt file formats ?
조회 수: 6 (최근 30일)
이전 댓글 표시
Surya Gnyawali
2018년 3월 21일
Hi I have a hyperspectral datacube in *.bil format and I need to convert it to *.cyt file format. Can you please help me with this code? Appreciate for the great help.
댓글 수: 7
Rik
2018년 3월 21일
If you can provide the file type descriptions, we can help you with implementation. Have you already tried your favorite internet search engine for a converter?
Rik
2018년 3월 21일
OK, so now we have a function to read the .bil files, we need a description of how a .cyt file works. Also, can you select the code and then click the {}Code button? Currently your function is unreadable.
Guillaume
2018년 3월 22일
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Loading a Hyperspectral Cube into Matlab %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Import the header file
[FileName,PathName,FilterIndex] =...
uigetfile({'*.hdr','Hyperspec Header File'},...
'Open Hyperspec Header File');
%%Gets the data from the Header File
fid = fopen([PathName,FileName]);
% fid is file ID
% fgetl gets one line
% char changes cell array to character array
% textscan helps parse around ' ' spaces
% char(Camera.Gain{3}) makes the third cell in Gain into a char array
% str2double converst the string of characters to a double number.
Data.Format = fgetl(fid);
DateStamp = fgetl(fid);
DateStamp = textscan(char(DateStamp),'%s%s%s%s%s%s%s%s',1);
Temp1 = char(DateStamp{3});
Temp2 = char(DateStamp{4});
Temp3 = char(DateStamp{5});
Temp4 = char(DateStamp{6});
Temp5 = char(DateStamp{7});
Temp6 = char(DateStamp{8});
DateStamp = [Temp1(3:length(Temp1)),' ',Temp2,' ',Temp3,' ',Temp4,...
' ',Temp5,' ',Temp6(1:(length(Temp6)-2))];
DataFormat.Samples = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Samples = str2double(char((DataFormat.Samples{3})));
DataFormat.Lines = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Lines = str2double(char((DataFormat.Lines{3})));
DataFormat.Bands = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Bands = str2double(char((DataFormat.Bands{3})));
DataFormat.HeaderOffset = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.HeaderOffset = str2double(char((DataFormat.HeaderOffset{4})));
DataFormat.FileType = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.FileType = ([char((DataFormat.FileType{3})),' ',...
char((DataFormat.FileType{4}))]);
Temp = textscan(char(fgetl(fid)),'%s%s%s%s',1);
Temp2 = str2double(char((Temp{4})));
switch Temp2
case 1
DataFormat.DataType = 'uint8';
case 2
DataFormat.DataType = 'int16';
case 3
DataFormat.DataType = 'int32';
case 4
DataFormat.DataType = 'float32';
case 5
DataFormat.DataType = 'double';
case 9
DataFormat.DataType = 'complex';
case 12
DataFormat.DataType = 'uint16';
end
DataFormat.Interleave = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Interleave = (char((DataFormat.Interleave{3})));
DataFormat.SensorType = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.SensorType = (char((DataFormat.SensorType{4})));
DataFormat.ByteOrder = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.ByteOrder = str2double(char((DataFormat.ByteOrder{4})));
if mod(DataFormat.ByteOrder,2) == 0
DataFormat.ByteOrder = 'ieee-le';
elseif mod(DataFormat.ByteOrder,2) == 1
DataFormat.ByteOrder = 'ieee-be';
end
DataFormat.Units = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.Units = (char((DataFormat.Units{4})));
Junk = fgetl(fid); % We just don't need this line, but we need to read past it.
%%Gets the wavelength data and puts it in a vector
i = 1;
j = 0;
a = [];
while i==1
b = fgetl(fid);
if b == -1
i=0;
elseif b(length(b))=='}'
a = cat(2,a,b(1:(length(b)-1)));
else
a = cat(2,a,b);
end
end
Wavelengths = str2num(a);
fclose(fid); % Closes the file.
clear Temp Temp2 Temp3 Temp4 Temp5 Temp6 a b Junk
%%Import the data file (UI version)
[FileNameData,PathName,FilterIndex] =...
uigetfile({'*.bil','Hyperspec Data File';'*.*','All Files'},...
'Open Hyperspec Data File', PathName) ;
% Set the Data Size
DataSize = [ DataFormat.Lines DataFormat.Samples DataFormat.Bands ];
% Load data with multibandread and assign to variable
HyperDataCube = multibandread([PathName,FileNameData], DataSize,...
DataFormat.DataType,DataFormat.HeaderOffset,...
DataFormat.Interleave, DataFormat.ByteOrder);
Mesh Plot of Data at specific wavelength.
Lambda = 10; % One element of the Wavelength vector
figure(3);mesh(fliplr(squeeze(HyperDataCube(:,:,Lambda))));view(180,90);
title(['Hyperspectral Data: \lambda = ',num2str(Wavelengths(Lambda)),...
' nm'],'FontSize',14);
xlabel('Pixels','FontSize',12);
ylabel('Pixels','FontSize',12);
Guillaume
2018년 3월 22일
File created by Cytospec - date: 17-Mar-2018 , time: 17:30:39
please do not modify this file
INS - IFS Vector 22 + IRscope II
MAN - Bruker
SRC - MAN
BSP - Globar
FIL - open
DET - MCT (microscope)
VEL - 20 kHz
LAS - 15799.1
AQM - double sided fw bw
SNG - automatic
LWN - 397.746
UWN - 994.8992
WVS - 25.9632
NOD - 24
DAT - 09-OCT-2000
TIM - 11:30:00
PHC - Mertz
PHR - 32
PIP -
ZFF - 4
RES - 8
APO - Happ-Genzel
APT - 45
STX - 30
STY - 30
TOS - absorbance
NOS - 8
XDI - 1192
YDI - 1600
SZX - 2400
SZY - 2400
SAM - B1760/98(Buch)
SAF - dry on CaF2
OPN - Peter Lasch
AS1 - dry colon adenocarcinoma sample
AS2 - colon sample, spectrally and spatially interpolated
AS3 - Hunter College, New York
BLO - 1 0 0 0
4 ORG (original data):
data imported as ascii files, date: 10-Oct-2000, time: 15:57:0
spectral interpolation factor: 2, NOD (old): 1323, new NOD: 662, date: 14-Apr-2006, time: 16:16:19
map dimensions (old): 84 x 84, new map dimensions: 42 x 42, date: 14-Apr-2006, time: 16:17:0
spectral interpolation factor: 16, NOD (old): 373, new NOD: 24, date: 17-Mar-2018, time: 17:14:29
2 PRE (preprocessed data):
spectral interpolation factor: 2, NOD (old): 1323, new NOD: 662, date: 14-Apr-2006, time: 16:16:19
map dimensions (old): 84 x 84, new map dimensions: 42 x 42, date: 14-Apr-2006, time: 16:17:0
2 DER (derivative data):
spectral interpolation factor: 2, NOD (old): 1323, new NOD: 662, date: 14-Apr-2006, time: 16:16:19
map dimensions (old): 84 x 84, new map dimensions: 42 x 42, date: 14-Apr-2006, time: 16:17:0
2 DEC (deconvolution data):
spectral interpolation factor: 2, NOD (old): 1323, new NOD: 662, date: 14-Apr-2006, time: 16:16:19
map dimensions (old): 84 x 84, new map dimensions: 42 x 42, date: 14-Apr-2006, time: 16:17:0
Guillaume
2018년 3월 22일
The last text is taken from a .cyt file. I am not familier about this file type.
Guillaume
2018년 3월 22일
Please use Comment on this question rather than spamming your own question with Answers. If people see that the question has already 3 answers, there's less chance they'll look at it and you'll have less chances of getting an answer.
Surya Gnyawali
2018년 3월 22일
편집: Guillaume
2018년 3월 22일
% Import the header file
[FileName,PathName,FilterIndex] =...
uigetfile({'*.hdr','Hyperspec Header File'},...
'Open Hyperspec Header File');
%%Gets the data from the Header File
fid = fopen([PathName,FileName]);
% fid is file ID
% fgetl gets one line
% char changes cell array to character array
% textscan helps parse around ' ' spaces
% char(Camera.Gain{3}) makes the third cell in Gain into a char array
% str2double converst the string of characters to a double number.
Data.Format = fgetl(fid);
DateStamp = fgetl(fid);
DateStamp = textscan(char(DateStamp),'%s%s%s%s%s%s%s%s',1);
Temp1 = char(DateStamp{3});
Temp2 = char(DateStamp{4});
Temp3 = char(DateStamp{5});
Temp4 = char(DateStamp{6});
Temp5 = char(DateStamp{7});
Temp6 = char(DateStamp{8});
DateStamp = [Temp1(3:length(Temp1)),' ',Temp2,' ',Temp3,' ',Temp4,...
' ',Temp5,' ',Temp6(1:(length(Temp6)-2))];
DataFormat.Samples = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Samples = str2double(char((DataFormat.Samples{3})));
DataFormat.Lines = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Lines = str2double(char((DataFormat.Lines{3})));
DataFormat.Bands = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Bands = str2double(char((DataFormat.Bands{3})));
DataFormat.HeaderOffset = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.HeaderOffset = str2double(char((DataFormat.HeaderOffset{4})));
DataFormat.FileType = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.FileType = ([char((DataFormat.FileType{3})),' ',...
char((DataFormat.FileType{4}))]);
Temp = textscan(char(fgetl(fid)),'%s%s%s%s',1);
Temp2 = str2double(char((Temp{4})));
switch Temp2
case 1
DataFormat.DataType = 'uint8';
case 2
DataFormat.DataType = 'int16';
case 3
DataFormat.DataType = 'int32';
case 4
DataFormat.DataType = 'float32';
case 5
DataFormat.DataType = 'double';
case 9
DataFormat.DataType = 'complex';
case 12
DataFormat.DataType = 'uint16';
end
DataFormat.Interleave = textscan(char(fgetl(fid)),'%s%s%s',1);
DataFormat.Interleave = (char((DataFormat.Interleave{3})));
DataFormat.SensorType = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.SensorType = (char((DataFormat.SensorType{4})));
DataFormat.ByteOrder = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.ByteOrder = str2double(char((DataFormat.ByteOrder{4})));
if mod(DataFormat.ByteOrder,2) == 0
DataFormat.ByteOrder = 'ieee-le';
elseif mod(DataFormat.ByteOrder,2) == 1
DataFormat.ByteOrder = 'ieee-be';
end
DataFormat.Units = textscan(char(fgetl(fid)),'%s%s%s%s',1);
DataFormat.Units = (char((DataFormat.Units{4})));
Junk = fgetl(fid); % We just don't need this line, but we need to read past it.
%%Gets the wavelength data and puts it in a vector
i = 1;
j = 0;
a = [];
while i==1
b = fgetl(fid);
if b == -1
i=0;
elseif b(length(b))=='}'
a = cat(2,a,b(1:(length(b)-1)));
else
a = cat(2,a,b);
end
end
Wavelengths = str2num(a);
fclose(fid); % Closes the file.
clear Temp Temp2 Temp3 Temp4 Temp5 Temp6 a b Junk
%%Import the data file (UI version)
[FileNameData,PathName,FilterIndex] =...
uigetfile({'*.bil','Hyperspec Data File';'*.*','All Files'},...
'Open Hyperspec Data File', PathName) ;
% Set the Data Size
DataSize = [ DataFormat.Lines DataFormat.Samples DataFormat.Bands ];
% Load data with multibandread and assign to variable
HyperDataCube = multibandread([PathName,FileNameData], DataSize,...
DataFormat.DataType,DataFormat.HeaderOffset,...
DataFormat.Interleave, DataFormat.ByteOrder);
Mesh Plot of Data at specific wavelength.
Lambda = 10; % One element of the Wavelength vector
figure(3);mesh(fliplr(squeeze(HyperDataCube(:,:,Lambda))));view(180,90);
title(['Hyperspectral Data: \lambda = ',num2str(Wavelengths(Lambda)),...
' nm'],'FontSize',14);
xlabel('Pixels','FontSize',12);
ylabel('Pixels','FontSize',12);
if true
% code
end
%------------------------------------------------------------
This link has all the matlab code used on the software "CytoSpec". You may find useful info on these files. Thanks a lot
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)