フィルターのクリア

My 4- D data is not supported by tiff files, what do I need to change so it does go into a .tiff file?

2 ビュー (過去 30 日間)
I am taking multiple images and tryting to save them using the code below, however the error I get when I run it is Error using writetif 4-D data not supported for TIFF files.
end; stoppreview(vid);
alpha=input('What do you want to name you file? ','s')
lambda = input('Variable ?', 's')
x = getdata(vid);
filename = alpha
RE = lambda
imwrite(x, [filename '.tif']);
clear lambda;

回答 (3 件)

Walter Roberson
Walter Roberson 2018 年 3 月 20 日
Is your data hyperspectral or is it multislice?
If your data is multislice then you can loop through the slices and imwrite each of them using writemode append
If your data is hyperspectral then is it geotiff? If so use geotiffwrite
If your image is hyperspectral then you have the choice of encoding it as AdditionalSamples or as subimages (but that is not what subimages are intended for) or as additional image entries (which is what writemode append will use)
Usually when there is a requirement to write beyond rgb or rgba or cmyk then it is for use with a particular post processing tool. In such a case you need to match the expectations of that tool rather than just writing whatever is convenient.
You should not expect to be able to write a 4d tiff in MATLAB and then double click on the image icon in your operating system and have it somehow displayed such as by volumetric display.
  7 件のコメント
Walter Roberson
Walter Roberson 2018 年 3 月 21 日
Could you explain further what you would be doing when you loop three times?
Merrilee Thomas
Merrilee Thomas 2018 年 3 月 21 日
Here is the code I wrote . I am using serial commands to control the LED lights, and I put the imaging in a for loop. I want to be able to image for 10secs, pause imaging, wait for 120 seconds, and then go through that loop three times. I changed the time on those in the loop just to be able to de-bug the code faster.
I am trying to then write this image using the append mode. However, I think that something is either going wrong when I am writing the apend, or I am loosing data every time the for loop goes through the iteration.
Thank you for your time and help, Merrilee Thomas

サインインしてコメントする。


Merrilee Thomas
Merrilee Thomas 2018 年 3 月 21 日
%first set up channel....
obj = instrfind('Port', 'COM3')
if isempty(obj)
obj = serial('COM3');
else
fclose(obj);
obj = obj(1)
end
fopen(obj);
set(obj, 'BaudRate', 115200);
set(obj, 'DataTerminalReady', 'off');
set(obj, 'FlowControl', 'hardware');
set(obj, 'Terminator', {10,10});
fprintf(obj, 'M 0');
data = query(obj, 'L? 0');
% this will set current for channel 1
% and the "L" is the limit.
fprintf(obj, 'L 0 700');
currentlimit = query(obj, 'L? 0');
% this will set current for channel 2
fprintf(obj, 'L 1 700');
currentlimit = query(obj, 'L? 1');
% to set or change "brightness Mode" also must turn off LED first before
% changing brightness if doing this in a command line.
fprintf(obj, 'BP 0 100');
brightnessvalue = query(obj, 'BP? 0');
% this will change brightness for channel 2
fprintf(obj, 'BP 0 100');
brightnessvalue = query(obj, 'BP? 0');
% this is the quickest on/off switch(470)
fprintf(obj, 'O 0 1'); %on
fprintf(obj, 'O 0 0'); %off
% and this turns on and off channel 2(560)!!!
fprintf(obj, 'O 1 1') % on
fprintf(obj, 'O 1 0') % off
% now set up imaging....
%vid = videoinput('hamamatsu', 1, 'MONO16_BIN2x2_1024x1024_FastMode');
vid = videoinput('hamamatsu', 1, 'MONO16_BIN4x4_512x512_FastMode');
src = getselectedsource(vid);
%vid.FramesPerTrigger = 10;
% TriggerRepeat is zero based and is always one
% less than the number of triggers.
%vid.TriggerRepeat = 2;
src.ExposureTime = .3;
%when I want to take multiple images, wait awhile and then takee more
%images in the same file.
for i = 1:2
tic
vid.FramesPerTrigger = 30;
fprintf(obj, 'O 0 1'); %on
preview(vid);
%fprintf(obj, 'O 0 1'); %on
start(vid),wait(vid);
toc
for l = 1:2
fprintf(obj, 'O 0 0'); %off
pause (10);
end;
end;
stoppreview(vid);
stop(vid);
alpha = input('What do you want to name you file? ','s');
first_time = true;
for frame_count = 1 : 3
x = getdata(vid);
filename = [alpha '.tif'];
for slnum = 1 : size(x, 4)
if first_time; mode = 'overwrite'; first_time = false; else mode = 'append'; end
imwrite( x(:,:,slnum), filename, 'writemode', mode);
end
end
closepreview(vid);
delete(vid);
clear vid;

Merrilee Thomas
Merrilee Thomas 2018 年 3 月 21 日
% now set up imaging....
%vid = videoinput('hamamatsu', 1, 'MONO16_BIN2x2_1024x1024_FastMode'); vid = videoinput('hamamatsu', 1, 'MONO16_BIN4x4_512x512_FastMode'); src = getselectedsource(vid); %vid.FramesPerTrigger = 10; % TriggerRepeat is zero based and is always one % less than the number of triggers.
%vid.TriggerRepeat = 2;
src.ExposureTime = .3; %when I want to take multiple images, wait awhile and then takee more %images in the same file.
tic vid.FramesPerTrigger = 30; fprintf(obj, 'O 0 1'); %on preview(vid); %fprintf(obj, 'O 0 1'); %on start(vid),wait(vid); toc fprintf(obj, 'O 0 0'); %off pause (10); vid.FramesPerTrigger = 30; fprintf(obj, 'O 0 1'); %on preview(vid); %fprintf(obj, 'O 0 1'); %on start(vid),wait(vid);
stoppreview(vid); stop(vid);
alpha = input('What do you want to name you file? ','s'); x = getdata(vid); filename = [alpha '.tif']; for slnum = 1 : size(x, 4) if slnum == 1; mode = 'overwrite'; else mode = 'append'; end imwrite( x(:,:,slnum), filename, 'writemode', mode); end
closepreview(vid); delete(vid); clear vid;
I took out the for loop and I still only get 30 frames... I think that when I call the trigger event it deletes the previous 30 frames. maybe

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by