Hello Everyone I have the following error please advise

7 views (last 30 days)
Error using matlab.images.internal.iptcheckmap (line 50)
Function IND2GRAY expected input number 2, MAP, to be a valid colormap. Valid colormaps must be nonempty, double, 2-D matrices
with 3 columns.
Error in iptcheckmap (line 28)
matlab.images.internal.iptcheckmap( ...
Error in ind2gray>parse_inputs (line 76)
iptcheckmap(varargin{2}, mfilename, 'MAP', 2);
Error in ind2gray (line 23)
[a,cm] = parse_inputs(varargin{:});
Error in Untitled2 (line 13)
f= ind2gray(i,map);
50 coder.internal.errorIf(true,'MATLAB:images:validate:badMapMatrix', ...
My code is:
clear all;
close all;
close all hidden
clc;
dbstop if error
a=imread('image_types_05.jpg');
figure(1),imshow(a),title('origanal image');
b=imnoise(a,'salt & pepper',.02);
figure(2),imshow(b),title('noisy image');
[i,map]=imread('pen_image.jpg');
f= ind2gray(i,map);
%Show original image:
figure,imshow(f, []);
% First: Spatial Filtering:
% Sobel Spatial Domain Filter
% Add some white noise:
f = double(f) + 40*randn(size(f));
%Display results (show all values)
figure(4),imshow(f, []),title('Noisy Grey Level Image');
h = fspecial('average'); %sobel
sfi = imfilter(double(f),h, 0, 'conv');
%show the image after pplying the sptaial filter "sobel"
figure(5),imshow(sfi, []);title('SOBEL Filtered Image');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Low Pass Filter
I= rgb2gray(a);
noisyImage=imnoise(I,'salt & pepper',.02);
imshow(noisyImage, [],'InitialMagnification', 'fit')
filterdImage = imgaussfilt(I, 5);
figure(6),imshow(filterdImage,'InitialMagnification', 'fit')
title('Low pass Filter Image');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% High Pass Filter
figure(7),imshow((I - filterdImage), 'InitialMagnification', 'fit')
title('High pass Filter Image');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Median Filter
I = imread('swan.jpg');
L= rgb2gray(i);
J = imnoise(L,'salt & pepper',0.02);
K = medfilt2(J);
figure(8),imshowpair(J,K,'montage'),title('Median Filter Image')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Laplacian Filter
%Set parameters of the filter to increase details smaller than 0.4.
A = imread('swan.jpg');
sigma = 0.4;
alpha = 0.5;
% Use fast local Laplacian filtering
B = locallapfilt(A, sigma, alpha);
%Display the original and filtered images side-by-side.
figure(9),imshowpair(A, B, 'montage'),title('Original and Laplacian Filter Image')
  3 Comments
Prabhan Purwar
Prabhan Purwar on 27 Jul 2021
Hi,
Kindly attach the images used while executing the code, so that we can replicate the issue and advice accurate workaround/solution.
Thanks

Sign in to comment.

Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by