【问题标题】:Image manipulation with Matlab - intensity and tif image使用 Matlab 进行图像处理 - 强度和 tif 图像
【发布时间】:2013-10-17 21:05:11
【问题描述】:

我必须分析一组图像,这些是我需要执行的操作:

  1. 对另一组图像求和(代码中称为开束),计算中值并将其旋转 90 度;
  2. 加载一组图像,列在文件“list.txt”中;
  3. 图像已按 3 组收集。对于每组,我想生成一个图像,其强度值是高于某个阈值的图像中值的 3 倍,否则等于强度值之和;
  4. 对于每组三幅图像,从组合图像(在 3. 中计算)中减去开束中值(在 1. 中计算)

考虑到使用上述过程生成的其中一个 tif,我认为最大值是 65211,这不是对应组的三个图像的 3* 中位数(我检查了像素位置)。您对为什么会发生这种情况以及我该如何解决有什么建议吗?

代码报告如下。谢谢!

%Here we calculate the average for the open beam
clear;
j = 0;
for i=1:5
   s = sprintf('/Users/Alberto/Desktop/Midi/17_OB_2.75/midi_%04i.fits',i);
   j = j+1;
   A(j,:,:) = uint16(fitsread(s));
end

OB_median = median(A,1);
OB_median = squeeze(OB_median);
OB_median_rot=rot90(OB_median);

%Here we calculate, for each projection, the average value from the three datasets

%Read list of images from text file
fid = fopen('/Users/Alberto/Desktop/Midi/list.txt', 'r');
a = textscan(fid, '%s');
fclose(fid);

%load images
j = 0;
for i = 1:1:42 %556 entries; 543 valid values
      s = sprintf('/Users/Alberto/Desktop/Midi/%s',a{1,1}{i,1});
      j = j+1;
      A(j,:,:) = uint16(fitsread(s));
end

threshold = 80 %This is a discretional number. I put it after noticing 
%that we get the same number of pixels with a value >100 if we use 80 or 50.

k = 0;
for ii = 1:3:42
    N(1,:,:) = A(ii,:,:);
    N(2,:,:) = A(ii+1,:,:);
    N(3,:,:) = A(ii+2,:,:);
    median_N = median(N,1);
    median_N = squeeze(median_N); 
    B(:,:) = zeros(2160,2592);
    for i = 1:1:2160
        for j = 1:1:2592
            RMS(i,j) = sqrt((double(N(1,i,j).^2) + double(N(2,i,j).^2) + double(N(3,i,j).^2))/3);
            if RMS(i,j) > threshold
               %B(i,j) = 30;
               B(i,j) = 3*median_N(i,j);
            else
               B(i,j) = A(ii,i,j) + A(ii+1,i,j) + A(ii+2,i,j);
               %B(i,j) = A(ii,i,j);
            end
        end
    end
    k = k+1;
    filename = sprintf('/Users/Alberto/Desktop/Midi/Edited_images/Despeckled_images/despeckled_image_%03i.tif',k);
    %Now we rotate the matrix
    B_rot=rot90(B);
    imwrite(B_rot, filename);
    %imwrite(uint16(B_rot), filename);
    %Now we subtract the OB median
    B_final_rot = double(B_rot) - 3*double(OB_median_rot);
    filename = sprintf('/Users/Alberto/Desktop/Midi/Edited_images/Final_image/final_image_%03i.tif',k);
    imwrite(uint16(B_final_rot), filename);
end

【问题讨论】:

    标签: image matlab max tiff


    【解决方案1】:

    uint16数据类型可以表示的最大整数是

    >> a=100000; uint16(a)
    
    ans =
    
      65535
    

    要规避此限制,您需要将数据重新缩放为double 类型并调整范围(图像对比度)以符合uint16 数据类型施加的限制,然后保存为uint16

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-21
      • 2014-03-18
      • 1970-01-01
      • 1970-01-01
      • 2014-06-01
      • 1970-01-01
      相关资源
      最近更新 更多