Rank: 4914 based on 22 downloads (last 30 days) and 1 file submitted
photo

payel ghosh

E-mail
Company/University
OGI

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by payel
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 22 3
  • 4.5
4.5 | 2 ratings
Comments and Ratings on payel's Files View all
Updated File Comment by Comments Rating
20 May 2013 label2rgb3D Creates a 4D rgb image from a 3D label image. Author: payel ghosh Orloff, Nathan

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 Orloff, Nathan

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);

10 Oct 2012 label2rgb3D Creates a 4D rgb image from a 3D label image. Author: payel ghosh Asadullah

please can you tell me how to export the 4D image from matlab?

25 Mar 2010 label2rgb3D Creates a 4D rgb image from a 3D label image. Author: payel ghosh Gough, Alex

Contact us