I am new to MATLAB and new to image processing.
I am going to find the contour of an image, so
leaf = imread('images\leaf.jpg')
SE = [1 1 1
1 1 1
1 1 1]
figure
imshow(leaf)
title("leaf_origin")
erosed_leaf = imerode(leaf,SE);
Contour = double(leaf) - double(erosed_leaf)
Contour=~Contour
figure
imshow(Contour)
This gives me an error while running imshow
Error using images.internal.imageDisplayValidateParams>validateCData (line 119)
If input is logical (binary), it must be two-dimensional.
Error in images.internal.imageDisplayValidateParams (line 27)
common_args.CData = validateCData(common_args.CData,image_type);
Error in images.internal.imageDisplayParseInputs (line 78)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 241)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});
if I remove ~ in front of contour, it works but gives incorrect output. Can anybody give me any hint about the error?
erosed_leaf = imerode(leaf,SE);
contour = double(leaf) - double(erosed_leaf);
contour = double(~contour);
figure();
imshow(contour);
Related
I am new to MATLAB image processing and trying to extract image features on the basis of colour thresholding but unable to go further. Right after selecting image pixel and I receive the following errors:
Error using getpts (line 174)
Interruption during mouse point selection.
Error in impixel>parse_inputs (line 199)
[xi,yi] = getpts(ancestor(h,'axes'));
Error in impixel (line 76)
[a,cm,xi,yi,x,y] = parse_inputs(varargin{:});
Error in featureextraction (line 5)
pval = impixel(a);
Here is my code:
oneToolImg = 'E:\Ujala Documents\hfu ss\forschungspraktikum\oneTool.jpg';
a = imread(oneToolImg);
figure(1)
imshow(a)
pval = impixel(a);
tool = (a(:,:,1)>91) & (a(:,:,2)>82) & (a(:,:,3)<252);
figure,imshow(tool)
The function is as expected:
%% plot 3D plot with true color marker
plot_Lab(4,Lab,1,'',12,0);
plot_Lab(mode,Lab,createnewfig,markercolor,markersize,storeme)
% This function visualizes several different CIE-Lab_plot plots from
% CIE-Lab coordinate data in 'Lab'.
I enter this:
plot_Lab(4,[45.9470,1.5130,5.2120],1,'',12,0);
and get the following error messages
Error using lab2xyz (line 25)
Incorrect number of columns in LAB data.
Error in applycform (line 88)
out = c.c_func(columndata, cdata{:});
Error in applycformsequence (line 11)
out = applycform(out, cforms{k});
Error in applycform (line 88)
out = c.c_func(columndata, cdata{:});
Error in plot_Lab (line 68)
RGB = applycform(Lab',cform);
Does anyone know where I got it wrong? Please help.
plot_Lab is not a built-in function. Therefore you are supposed to provide its code or link, so one could follow you.
According to the link,
% Lab [3 x n] -> Lab coordinates of n datapoints
Lab is supposed to be 3 x n. What you are provided is 1 x 3. So, you probably need to transpose it:
plot_Lab(4, [45.9470,1.5130,5.2120].', 1, '', 12, 0);
I have tried to calculate adjacent pixel correlation of 2 images. I am getting the answer for the encrypted images but not for the original plain text image.
It's showing some error which i am unable to understand. I have given the code which i used below along with the error message.
Please help.
P = imread('cameraman.tif');
x1 = P(:,1:end-1);
y1 = P(:,2:end);
r_xy1 = corrcoef(x1,y1);
scatter(x1,y1);
For this I am getting an error message:
Error using bsxfun Mixed integer class inputs are not supported.
Error in cov (line 93) xc = bsxfun(#minus,x,sum(x,1)/m); % Remove
mean
Error in corrcoef>correl (line 209) r = cov(x);
Error in corrcoef (line 92) r = correl(x);
Error in apc_PT (line 4) r_xy1 = corrcoef(x1,y1);
The same code worked for encrypted image. Dont know what's wrong.
You should cast the result of imread to double:
P = double(imread(...));
This will fix your error with corrcoef.
Edit Also, as noticed in the comments you have to use vectors in scatter:
scatter(x1(:), y1(:));
Best,
I'm trying to blur a grayscale image using Gaussian low pass filter( 5*5 kernal).I tried the following code.
I = imread('Lena.png');
G = fspecial('gaussian',[5 5],2);
Ig = imfilter(I,G,'same');
imshow(Ig);
But I'm getting an error in file 'meshgrid.m' as follows.
Error: File: meshgrid.m Line: 1 Column: 5
The input character is not valid in MATLAB statements or expressions.
Error in fspecial (line 145)
[x,y] = meshgrid(-siz(2):siz(2),-siz(1):siz(1));
Error in Untitled2 (line 2)
G = fspecial('gaussian',[5 5],2);
I'm not understanding what the error is.Can anyone help me please.The input image that I used is uploaded below('Lena.png').Thanks in advance
I have this piece of code and what i'm trying to do is to fill this function plot that is made with timeseries. I tried full and area methods, but didn't have any success to implement them. I also tried to plot using TP1out to plot instead of TP1, but doing this i lose my ZOH interpolation and the graph become linear. If someone have an idea how to solve this i would be thankful.
TP1out = [1 0 0 1 0];
time = 0:4;
TP1 = timeseries(TP1out,time,'name','task 1');
TP1.DataInfo.Interpolation = tsdata.interpolation('zoh');
plot(TP1), grid on
axis([0 4 0 1.5])
I know it's stupid, but i tried many stuff, like:
>> area(TP1)
Undefined function 'real' for input arguments of type
'timeseries'.
Error in xychk (line 48)
x = real(y); y = imag(y);
Error in area (line 45)
[msg,x,y] = xychk(args{1:nargs},'plot');
>> area(time,TP1)
Error using specgraph.areaseries/set
Array must be numeric or logical.
Error in specgraph.areaseries (line 40)
set(h,args{:})
Error in area (line 83)
h = [h
specgraph.areaseries('YData',datachk(y(:,k)),
...
>> area(time,TP1.Data)
Error using area (line 46)
Inputs must be 2-D.