Dear sir, I want to convert logical (binary image) to grayscale image for LBP, Is it possible ? please answer me,Thanks in advance
7 views (last 30 days)
Show older comments
Sir, I have attached binary hand vein image, i want to apply LBP (local Binary Pattern) on this image, but this requires grayscale image, so that needs to convert from binary to grayscale image, please help to sort out this, thanks..
0 Comments
Answers (2)
Darin Hitchings
on 19 Oct 2022
I'm doing this same operation you're asking about here manually... although I'm certain Matlab has a toolbox function for it. A grey-scale image is just an image (which in Matlab is a matrix of dimension MxNx3) in which the same value exists across each color channel so that image(i,j,k_1) == image(i, j, k_2) for all pairs of k_1, k_2.
I'm multiplying by 255 because an RGB image typically has 0-255 possible values for each channel where 0 is for black and 255 is for white.
image( ) will display a matrix as an image and assume that the values are already scaled to the range 0-255. The function imagesc( ) would do that scaling for you (in which case you don't need to multiply by 255). It just depends on how you want to look at the data.
Also beware that you can use 'axis xy' to make the y axis increase as you go up the image instead of down.
%self.occupancy_map is a logical image (binary)
image_ = zeros(size(self.occupancy_map,1),size(self.occupancy_map,2),3);
image_(:,:,1) = 255*self.occupancy_map;
image_(:,:,2) = 255*self.occupancy_map;
image_(:,:,3) = 255*self.occupancy_map;
And you can define your own origin for the image to be other than (0,0) by using this code:
set(gca, 'XTick', xticks, 'XTickLabel', xticks_labels); % where xticks_labels is an array of strings (use the strings( ) function to create it from an array of doubles )
set(gca, 'YTick', yticks, 'YTickLabel', yticks_labels);
0 Comments
Walter Roberson
on 19 Oct 2022
Edited: Walter Roberson
on 19 Oct 2022
gray = im2uint8(YourMatrix);
rgb = gray(:, :, [1 1 1]);
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!