Rank: 7526 based on 5 downloads (last 30 days) and 1 file submitted
photo

payel ghosh

E-mail
Company/University
OGI

Personal Profile:

 

Watch this Author's files

 

Files Posted by payel ghosh
Updated   File Tags Downloads
(last 30 days)
Comments Rating
25 Aug 2005 label2rgb3D Creates a 4D rgb image from a 3D label image. Author: payel ghosh color, label2rgb, 3d, rgb, label, matrix 5 5
  • 4.0
4.0 | 3 ratings
Comments and Ratings on payel ghosh's Files View all
Updated File Comment by Comments Rating
21 Apr 2014 label2rgb3D Creates a 4D rgb image from a 3D label image. Author: payel ghosh Nicolas Broguiere

I would add that the code of Nathan worked for me, thanks ;)

21 Apr 2014 label2rgb3D Creates a 4D rgb image from a 3D label image. Author: payel ghosh Nicolas Broguiere

Didn't work for me either (Matlab2013b), even though the description looked perfect... thanks for your work, but might need an update. Best,

21 Apr 2014 label2rgb3D Creates a 4D rgb image from a 3D label image. Author: payel ghosh Nicolas Broguiere

20 May 2013 label2rgb3D Creates a 4D rgb image from a 3D label image. Author: payel ghosh Nathan Orloff

function rgbcell = label2rgb3d(lblstack)
%label2rgb3d(lblstack) take a labeled stack and turn it into a truecolor image.
% get all of the unique ind
ind = unique(lblstack);
cmap = jet(numel(ind));
images = stack2cell(lblstack);
rgbcell = cellfun(@(x) im2double(label2rgb(x, cmap, 'k')), images, 'UniformOutput', false);

function images = stack2cell(stack)
%stack2cell(stack) convert a stack of data into a cell array
% Detailed explanation goes here
% See also cell2stack
images = num2cell(zeros(size(stack,3),1));
if numel(size(stack)) == 3 % bw and grayscale images
for ii = 1:size(stack,3)
images{ii} = stack(:,:,ii);
end
elseif numel(size(stack)) == 4 % truecolor data
for ii = 1:size(stack,4)
images{ii} = stack(:,:,:,ii);
end
end
end

function stack = cell2stack(images)
%cell2stack converts a cell array of images to a stack (or cube of images)
% converts a cell array of images to a stack (or cube of images)
p = numel(images);
dims = size(images{1});
stack = zeros([dims,p]);
if numel(dims) == 2 % bw and grayscale images
for ii = 1:p
stack(:,:,ii) = images{ii};
end
elseif numel(dims) == 3 % truecolor data
for ii = 1:p
stack(:,:,:,ii) = images{ii};
end
end

end

This should be all you need to do this. While manipulating multidimensional data I found cell2stack and stack2cell incredibly useful. Also, cellfun is a very fast way to implement many of the image processing routines. HTH- Nate

20 May 2013 label2rgb3D Creates a 4D rgb image from a 3D label image. Author: payel ghosh Nathan Orloff

I think this might be better. Also, I tried your code and I got a incorrect results, but I didn't really try very hard to make it work.

ind = unique(lblstack);
cmap = jet(numel(ind));
images = cell2stack(lblstack);
rgbcell = cellfun(@(x) label2rgb(x, cmap, 'k'), images, 'UniformOutput', false);

Contact us