link b.jpg
i=imread('b.jpg');
i1=rgb2gray(i);
i2=im2double(i);
j=log(1+i2);
1.
now this for get histograme of image.
imhist(j);
say error:
??? Error using ==> iptcheckinput
Function IMHIST expected its first input, I or X, to be two-dimensional.
Error in ==> imhist>parse_inputs at 270
iptcheckinput(a, {'double','uint8','logical','uint16','int16','single'}, ...
Error in ==> imhist at 57
[a, n, isScaled, top, map] = parse_inputs(varargin{:});
=============================================================================
2.how can draw diagrame of function?
plot(j,i2);
??? Error using ==> plot
Data may not have more than 2 dimensions
==============================================================================
3.how can get gamma of j
I think, you have made a mistake in the beginning
i=imread('b.jpg');
i1=rgb2gray(i);
i2=im2double(i); % POSSIBLE MISTAKE
i2=im2double(i1);
j=log(1+i2);
After this correction, both (1) imhist(j) and (2) plot(j,i2); work OK. For gamma correction you can refer to either of these : Link-A, Link-B.
Related
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 am trying to use imhist to display the histogram of a uint8 .jpg, however I am getting this error:
Error using imhist Expected input number 1, I or X, to be
two-dimensional.
Error in imhist>parse_inputs (line 278) validateattributes(a,
{'double','uint8','int8','logical','uint16','int16','single','uint32',
'int32'}, ...
Error in imhist (line 60) [a, n, isScaled, top, map] =
parse_inputs(varargin{:});
Here is my image information:
whos f Name Size Bytes Class
Attributes
f 2988x5312x3 47616768 uint8
Do I need to convert my image to another data class? I would appreciate any help on this.
Thanks!
The cause of error is because your image is RGB and imhist does not deal with that. To work around this you can either use a single channel:
imhist(YourImage(:,:,Channel));
or convert from RGB to grayscale:
imhist(rgb2gray(YourImage));
That should work fine now.
I tried the quadtree decomposition using the following code, but every time I am getting an error.
>> I=imread('hyd.tif');
>> S=qtdecomp(I)
Or
>> I=imread('hyd.tif');
>> S=qtdecomp(I,.27)
Error:
??? Error using ==> qtdecomp>ParseInputs at 145
A must be two-dimensional
Error in ==> qtdecomp at 88
[A, func, params, minDim, maxDim] = ParseInputs(varargin{:});
The culprit is due to your image being in colour or RGB. Try converting the image to grayscale before using the algorithm.
I = imread('hyd.tif');
Igray = rgb2gray(I);
S = qtdecomp(Igray);
Also make sure that your image dimensions are of a power of 2 or else the quadtree decomposition algorithm will not work.
I try to plot these 2 graphs on the same plot but matlab return error 'can't divide by zero' and refer me to sinc of 0.
I don't know what to do bc sinc(0)=1, I don't understand the problem.
my code:
syms x
ezplot(heaviside(x+1) - heaviside(x-1), [-2, 2])
hold
t=-2:0.1:2;
syms k
r=symsum( ((sinc(k/2)/2)*exp((1i)*k*pi*(t/2))), -1,1);
plot(t,r)
problem:
??? Error: File: aa.m Line: 6 Column: 18
Unexpected MATLAB expression.
Current plot held
??? Error using ==> mupadmex
Error in MuPAD command: Division by zero [_power];
during evaluation of 'sum::sum'
Error in ==> sym.symsum at 74
r = mupadmex('symobj::map',f.s,'symobj::symsum',x.s,a.s,b.s);
Error in ==> aa at 6
r=symsum( ((sinc(k/2)/2)*exp((1i)*k*pi*(t/2))), -1,1);
Use this alternative definition for sinc:
ssinc=#(X)(1./(gamma(1+X).*gamma(1-X)))
syms x
ezplot(heaviside(x+1) - heaviside(x-1), [-2, 2])
hold
t=-2:0.1:2;
syms k
r=symsum( ((ssinc(k/2)/2)*exp((1i)*k*pi*(t/2))), -1,1);
plot(t,r)
This code uses an alternative definition of the sinc function:
(Source: Wikipedia)
Another solution, instead of using an alternative definition with the gamma function, I added a correction to redefine the x=0 point.
The original function has a 0/0 situation, I redefined it using a correction function with correction(0)=1 and correction(1)=0 otherwise. This changes to function to 1/1 at sinc(0).
%correction(0)=1, correction(x)=0 otherwise. A little bit idiotic, but I'm unable to define this in a simpler way which is compartible to the symbolic toolbox:
correction=#(x)(((heaviside(x)-.5).^2)-.25)*-4
%redefine sinc using the original function, but use correction(x) to fix sinc(0)
ssinc=#(x)((sin(pi*x)+correction(x))./((pi*x)+correction(x)))
syms x
ezplot(heaviside(x+1) - heaviside(x-1), [-2, 2])
hold
t=-2:0.1:2;
syms k
r=symsum( ((ssinc(k/2)/2)*exp((1i)*k*pi*(t/2))), -1,1);
plot(t,r)