Why am I getting an error when I use grayscale images with

Technical Source
2 min readJan 17, 2022

--

Why am I getting an error when I use grayscale images with “makehdr”in Image Processing Toolbox 8.1 (R2012b)?

I am receiving the following error when trying to use the “makehdr” utility.

low dynamic images must be RGB

I suspect the reason is that my images are black-and-white. Is there any workaround for this issue?

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

“makehdr” works only on RGB images. The workaround for this issue is to convert the grayscale image to an RGB image.

Grayscale images are 2D (m x n) matrices, while RGB images are 3D (m x n x 3) matrices. Therefore one must expand the 2D matrix to fill the 3D matrix. This can be accomplished a couple ways

1. Use REPMAT to replicate the 2D matrix 3 times.

% Step 1 - Load grayscale image
imGray = imread('grayscaleImage.tif');
% Step 2 - Replicate image into RGB layers using REPMAT
nRV = 1; % Number Of Replications Vertically
nRH = 1; % Number Of Replications Horizontally
nRL = 3; % Number Of Replication Layers
imRGB = repmat(imGray,[nRV, nRH, nRL]); % Replicate grayscale image 3 times
% Step 3 - Write resized image to file
imageName = 'rgbImage.tif';
imwrite(imRGB,imageName)

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet