Transparency violation error when using parfor
    3 ビュー (過去 30 日間)
  
       古いコメントを表示
    
[edit] the problem is the function call of 'save()' in the parfor loop. the solution is found here: http://ch.mathworks.com/matlabcentral/answers/135285-how-do-i-use-save-with-a-parfor-loop-using-parallel-computing-toolbox]/edit]
dear all, I try to postprocess a significant amount of images. I want to parallelize it. I tried to consider the coding restrictions that come with the parfor loop, but i still run into the
Error using test_parloop (line 21)
Transparency violation error.
 See Parallel Computing Toolbox documentation about
 Transparency
I posted below the code. thank you for any help!
clear all
clc
load('xls_file')   % contains the logfile of all images
flag={'emp','d2o','cl3'}; % three folders / cases
readpath='C:\data\tomo_HS14\02_rawdata\';
writepath='C:\data\tomo_HS14\processed\';
if matlabpool('size') == 0 % checking to see if my pool is already open
    matlabpool open 3
end
for i =3%1:size(flag) %iterate cases
    jmax=size(xls{i},1);
      % generate path strings
      rpath=strcat(writepath,'1raw\',flag{i},'\'); %read
      wpath=strcat(writepath,'2flt\',flag{i},'\'); %write
      parfor j=1:jmax
          if xls{i}{j,14}~=0 %check if the file is 'healthy'
              % generate file name string
              rfile=strcat(flag{i},'_',sprintf('%04d',j),'.fits');    %read
              wfile=strcat(flag{i},'_filt_',sprintf('%04d',j),'.mat');%write
              % read image
              im=im2double(fitsread(strcat(rpath,rfile))');
              % all sorts of image processing here
              % write image
              save(strcat(wpath,wfile),'im')
              % generate command line output
              fprintf('_%d',j)
              if mod(j,100)==0
                  fprintf('\n')
              end
          end
      end
  end
  matlabpool close
4 件のコメント
  Walter Roberson
      
      
 2015 年 7 月 25 日
				When you use fullfile() you do not need to worry about whether you are executing on MS Windows or on OS-X or Linux, and you do not have to think about whether particular strings have already had the path separator or if you need to add the path separator. It simplifies the code, and it also makes it clearer to readers. Problems with incorrect paths and assumptions about directories are common when people put together filenames using strcat(), but people who use fullfile() are more likely to handle names properly in my experience. (In particular, people who use dir() to find file names and do not use fullfile() with the .name field often make mistakes in building the name.)
回答 (1 件)
  casper.dcl
 2017 年 10 月 13 日
        https://uk.mathworks.com/help/distcomp/transparency.html?requestedDomain=www.mathworks.com
You can't `save` in a `parfor` loop.
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Big Data Processing についてさらに検索
			
	製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


