I have a confusion about ROC curve and hopefully you can help me!
To plot ROC, i was naively using a simple command as plot(False_alarm_rate,Hit_rate,'-'). But, it is not exactly the same as perfcurve plot. To use this function, i wrote the following script
Q=reshape([Hit_rate False_alarm_rate],[],1);
Labels=[]; Labels = ones(size(Q,1),1);
Labels(end/2+1:end) = 0;
PosClass = 1;
X=[];Y=[];
[X Y T,AUC] = perfcurve(Labels,Q,PosClass);
figure, plot(X,Y,'r') % ROC
could you please tell me , what i am missing here?
BTW, can we calculate d-prime from output of perfcurve?
thanks in advance,
Karlo
ROC is basically sensitivity vs specificity curve.Its very easy and time consuming. Hope I can help you if I get below details:
1.what type of data you are using?
2.Which parameter of the data you want in curve?
3.Did you ever tried to plot ROC using sensitivity and specificity data?
Related
How could I start to write a Gaussian Radial Basis Function in Mathematica? Please provide coding as references if possible. I have already tried but I still could not run it. Please show some guide to help me run it.
Without more details, it's impossible to give any better answer than this.
GaussionRadialBasis[x_Real, parameter_Real:1] := Exp[-parameter*x^2];
How can I implement region filling(Conditional Dilation) algorithm that The algorithm terminates at step k if Xk=Xk-1 with matlab!
Fill this image with region filling algorithm in matlab
You can use the imfill function from the Image Processing toolbox.
You can either specify the points where to start the filling, or use the 'holes' option to fill all holes:
I = imread('http://i.stack.imgur.com/BkHkg.png');
I = I>0; % convert to binary image
J = imfill(I,'holes');
--
If you want to implement the algorithm yourself, then please specify what algorithm you are using, add the code you have and tell us exactly what problems you are having. Nobody here will write the code for you from scratch, but we are glad to help with problems.
I known that the question can be not satisfy for forum,but I think I can find the help from many smart image processing guys. My question is that, I have a image include texture and non-texture in image. How to detect the region that is texture region? Could you suggest to me any algorithm or parameter to distinguish non-texture region and texture region?
Thank you so much
UPDATE:
Based on the suggestion about Gray Level Matrix. I use a tool to extract that texture feature. However, I don't know which is best for my case. Let see the my result and explain help me which feature will be chosen
#rayryeng: Could you said to me what is purpose of Neighboring gray-level dependence matrix (NGLDM). How to use it in my case?
You can use texture descriptors such as those used in MPEG-7 :
Homogeneous Texture Descriptor (HTD)
Texture Browsing Descriptor (TBD)
Edge Histogram Descriptor (EHD)
You can find the details in some scientific papers such as Evaluation and comparison of texture descriptors proposed in MPEG-7 or Texture Descriptors in MPEG-7
A basic way to compute texture descriptors is to use Gabor filter. Some of MPEG-7 descriptors are based on it.
You can also take a look to the Grey-Level Co-occurrence Matrix texture measurements.
I am not sure if this is a valid way, or anybody uses this approach (I could not find any scholar papers) but I have an intuitive approach which I used a couple of times and worked fine for me.
I calculate the number of valid SURF features in an image and sort images with respect to the number of features. As the number of features increase, texture level also increases in my intuition. Below is my Matlab function that extract the number of features:
function [num_pts] = im2surf_feature(im)
if nargin>=1 && ischar(im) && exist(im, 'file')
im = imread(im);
end
if size(im,3)==3
im = rgb2gray(im);
end
ptsI1 = detectSURFFeatures(im);
[~, validPtsI1] = extractFeatures(im, ptsI1);
num_pts = size(validPtsI1,1);
end
detectSURFFeatures and extractFeatures are Matlab functions.
Note: I know this is a very late answer, but maybe someone can use it or give me feedback as to why this method is good or bad.
I am trying to implement the 2D correlation algorithm to detect the position of an object in the image, i don't want to use any built in function estimates 2d correlation.
Here is my code:
I=imread('image.tif'); % image is a black image contains white letters.
h=imread('template.tif'); %template is a small image taken from the original image, it contains one white letter.
I=double(I);
h=double(h);
[nrows ncolumns]=size(I);
[nrows2 ncolumns2]=size(h);
C=zeros(nrows,ncolumns);
for u=1:(nrows-nrows2+1)
for v=1:(ncolumns-ncolumns2+1)
for x=1:nrows2
for y=1:ncolumns2
C(u,v)=C(u,v)+(h(x,y)*I(u+x-1,v+y-1));
end
end
end
end
[maxC,ind] = max(C(:));
[m,n] = ind2sub(size(C),ind) % the index represents the position of the letter.
output_image=(3.55/4).*C./100000;
imshow(uint8(output_image));
I think it is working! but it is very slow.
How can i replace the following code by a better code to speed up the algorithm?
for x=1:nrows2
for y=1:ncolumns2
C(u,v)=C(u,v)+(h(x,y)*I(u+x-1,v+y-1));
end
end
I am thinking that in every time i have the following two matrices
h(1:nrows2,1:ncolumns2) and I(u:u+nrows2-1,v:v+ncolumns2-1)
another question, are there any improvements?
thanks.
Whenever you can, try to use matrix ops. So try something like:
rowInds = (1:nrows2)-1;
colInds = (1:ncolumns2)-1;
temp = h.*I(u+rowInds,v+colInds);
C(u,v) = sum(temp(:));
Instead of:
for x=1:nrows2
for y=1:ncolumns2
C(u,v)=C(u,v)+(h(x,y)*I(u+x-1,v+y-1));
end
end
Yes there are many improvements. You don't need a for loop at all. Since you do not want to use matlab's xcorr2 function, you can use conv2. See the answer I gave here.
How about determining the cross correlation in the Fourier domain, following the cross-correlation theorem? That should guarantee a dramatic speed increase.
Hello,
I have a segmented image as shown. Is there a way to smoothen the lines so that it does not look so wavy? Thanks.
The following code requires Image Processing Toolbox:
url = 'http://i182.photobucket.com/albums/x11/veronicafmy/FYP/picture5segmentedimage.jpg';
rgb = imread(url);
bw = im2bw(rgb2gray(rgb), 0.5);
se = strel('line',50,74); % 74 degrees determined by inspection
bw2 = imclose(bw,se);
se2 = strel('line',50,74+90);
bw3 = imclose(bw2,se2);
Here's the result:
Optional step: postprocess by thinning:
bw4 = bwmorph(bw3,'thin',inf);
I think you should ask yourself why it has to be smoother. If you have segmented an image and gotten that result, are you sure that smoothening will give you a correct result?
If it does then Steve Eddins answer seems to do the trick.
If, on the other hand, the object you are trying to segment is much smoother than the result I'd suggest one of two approaches.
If the target object is a cross (two lines), I'd probably calculate the lines and change the representation to two line segments. These can then be rendered at whatever precision and smoothness. To do this you could either find the center and rotation using some kind of feature detection algorithm, or you could use hough transforms to find the lines. The latter is probably much simpler.
If the target can have any form then I'd look into a better segmentation algorithm. There are segmentation algorithms that is not based on hard thresholds. I have used graph partitioning algorithms for this, and while slow, they work well.