필터 지우기
필터 지우기

saving multilabeled RGB image stack as Text(.txt) file

조회 수: 2 (최근 30일)
Asadullah
Asadullah 2012년 10월 5일
Hi All
I have a stack of 200 microstructure images, the grains in images have been labeled by using 3D watershed segmentation technique and then converted to RGB by label2rgb() function with 'colorcube' as colormap. I have used the following code to save this dataset as text file, but this code only saves the voxel information of each 3D label to text file but not the color of each label(when i visualized by using this resulting text file then it seems like a grayscale image). I do not know how to save this 3D dataset to text file which contain information of each 3D label along with its color, please help me. The code i am using is:
clc;
clear all;
n=200;
fidIn=0;
fidOut=fopen('labeled.txt', 'w');
for i=1:n
strFileName=strcat('section',num2str(i),'.tiff');
% here 'section' is the colored RGB image
fidIn=imread(strFileName);
[M,N]=size(fidIn);
x = repmat('%d ',1,(N-1));
fprintf(fidOut,[x,'%d\n'],fidIn);
end
fclose(fidOut);
Any help will be highly appreciated.
Thanks

채택된 답변

Image Analyst
Image Analyst 2012년 10월 5일
I don't know what that code is but it doesn't seem related to what you said - no label2rgb() call, etc.
Basically, just scan each colored image writing it's values
fid = fopen('labeled.txt', 'wt'); % Note: wt.
for row = 1 : rows
for col = 1 : cols
value = labeledImage(row, column);
fprintf(fid, '%d %d %d %f %f %f\n', row, col, value, colorMap(value, 1), colorMap(value, 2), colorMap(value, 2),);
end
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by