File Comment by Comment
11 Dec 2014 Bradley local image thresholding A fast an well performing local image thresholding method. Michael scheinfeild

excellent code help binarize image

27 Oct 2014 Rotate an image around a point Performs rotation of an image around any point inside of the image. Bauyrzhan Aubakir

27 Oct 2014 Rotate an image around a point Performs rotation of an image around any point inside of the image. Jan Motl

Thanks Maider for the comment.

Regarding the small angle problem, I believe that for small angles (like 0.1) and small images (like 300x200) rotateAround should give images identical with the source images (and also identical with the results from imrotate).

Only for bigger images (like 1000x1000) or bigger angles (like 1) the results should be different.

Regarding the loosing of pixels. If I rotate an image by 0 degrees, I should always get the original image (regardless of the point of rotation or image size). With round function, I am not loosing any pixel on testing machines. With floor function, I am loosing pixels.

But it is possible, that internals of imrotate can differ in rounding.

Nevertheless, the function as it is behaves correctly in MATLAB R2012b and MATLAB R2014a.

24 Oct 2014 Bernsen local image thresholding Implementation of Bernsen's thresholding method. Jan Motl

I have retested Bersen thresholding on several operating systems and versions of MATLAB. In all configurations it worked.

But keep in mind that only 2-dimensinal matrices in uint8 are supported. However, if you load a jpg file with imread command then you get a 3-dimensional uint8 matrix (even if the image is grayscale). Hence you have reduce dimensionality.

Also, it is generally advisable to test several sizes of the neighborhood to get good results.

For example, to get the illustration image from the attached jpg, use following command:

The description of the algorithm (and the parameters) is for example at:
http://fiji.sc/wiki/index.php/Auto_Local_Threshold#Bernsen

If you are still having difficulties with the code, let me know more details (like version of MATALB, OS, example image, the minimal code reproducing the error,...) and I will do my best to help you.

23 Oct 2014 Bernsen local image thresholding Implementation of Bernsen's thresholding method. Rohan Ghare

not working proper
what are different parameters of bernsen

26 Aug 2014 Rotate an image around a point Performs rotation of an image around any point inside of the image. Ehsan

It's Really work!
Thank you, your code solve a major problem in my project.............

13 Aug 2014 Rotate an image around a point Performs rotation of an image around any point inside of the image. Maider

I meant to change lines 35 and 36 in rotateAround from
shiftX = round(pointX-(centerX+newX));
shiftY = round(pointY-(centerY-newY));
to
shiftX = floor(pointX-(centerX+newX));
shiftY = floor(pointY-(centerY-newY));

13 Aug 2014 Rotate an image around a point Performs rotation of an image around any point inside of the image. Maider

Thanks for this submision. This is a very clever way to use imrotate.
But the function can be improved. For example:
1. If you use rotateAround_test and use pointX = 1; and pointY = 1; and run, the result shows that position (1,1) and (2,1) are black as they belong to the lost pixels in the rotation, that should not happen.
2. It does not work well with small angles such as 0.1. In such case rotateAround produces a rotation identical to imrotate.
Running
%% Set test parameters
imageX = 300;
imageY = 200;
pointX = 1;
pointY = 1;
angle = 0.1;

%% Create test image - black dot on white field
image = ones(imageY, imageX);
image(pointY, pointX) = 0;
rot = imrotate(image,angle,'bilinear', 'crop');

%% Rotate the image around the black dot
rotated = rotateAround(image, pointY, pointX, angle,'bilinear');

>> norm(rot - rotated)

ans =

0

I suggest to change lines 35 and 36 in rotateAround from
shiftX = round(pointX-(centerX+newX));
shiftY = round(pointY-(centerY-newY));
to
centerX = floor(imageWidth/2+1);
centerY = floor(imageHeight/2+1);

That solved both problems for me.

19 Jul 2014 Rotate an image around a point Performs rotation of an image around any point inside of the image. Gaurav Mittal

Thanks, works great.

10 Jun 2014 Straighten image The function finds the document orientation. Matthew

01 May 2014 Rotate an image around a point Performs rotation of an image around any point inside of the image. Yun Inn

21 Apr 2014 Rotate an image around a point Performs rotation of an image around any point inside of the image. Jan Motl

Thanks for suggestion. I swapped the parameters of the function call.

01 Apr 2014 Remove ghosts from binarized images This method removes speckles in the binarized images. Jan Motl

Thanks for reporting. I have added the missing example image. Let me know if you have more issues.

01 Apr 2014 Remove ghosts from binarized images This method removes speckles in the binarized images. jacky chen

where is the demo image ?

03 Mar 2014 Rotate an image around a point Performs rotation of an image around any point inside of the image. Juan P. Viera

Really useful. I think you should change the rotation line:
for

17 Feb 2014 Bradley local image thresholding A fast an well performing local image thresholding method. haem

22 Oct 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. drdrb

% Also use this:

output = double(output(...
2:2:end-1,2:2:end-1));

[height,width]=size(image);
height2=ceil(height/2);
width2=ceil(width/2);
height2l=floor(height/2);
width2l=floor(width/2);
matrix1=spalloc(height2,height,height2);
for j=1:height2l
matrix1(j,j*2)=1;
end
matrix2=spalloc(width,width2,width2);
for j=1:width2l
matrix2(j*2,j)=1;
end
output=matrix1*double(output)* matrix2;
output=output(1:end-1,1:end-1);

%sparse matrices are fancy, but just %avoiding "for" at any price(even %readability) can get you farther.

22 Oct 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. drdrb

% Also use this:

output = double(output(...
2:2:end-1,2:2:end-1));

% istaid of this:

[height,width]=size(image);
height2=ceil(height/2);
width2=ceil(width/2);
height2l=floor(height/2);
width2l=floor(width/2);
matrix1=spalloc(height2,height,height2);
for j=1:height2l
matrix1(j,j*2)=1;
end
matrix2=spalloc(width,width2,width2);
for j=1:width2l
matrix2(j*2,j)=1;
end
output=matrix1*double(output)* matrix2;
output=output(1:end-1,1:end-1);

%sparse matrices are fancy, but just %avoiding "for" at any price(even %readability) can get you farther.

22 Oct 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. drdrb

% Thank you!
% It's just what I was searching for!
% Great piece of code
% Just to note that this:

output=zeros(2*size(image));
output(2:2:end,2:2:end)=image;

% is much faster then this:

[height,width]=size(image);
matrix1=spalloc(2*height,height,height);
for i=1:height
matrix1(2*i,i)=1;%#ok
end
matrix2=spalloc(width,2*width,width);
for i=1:width
matrix2(i,2*i)=1;%#ok
end
output=matrix1*double(image)*matrix2;

22 Aug 2013 Feng local image thresholding Feng binarization method is well suited for ill illuminated or stained documents. Derya

Thanks for sharing these interesting thresholding methods.

05 Aug 2013 Meanthresh local image thresholding Meanthresh performs a simple local image thresholding. ashkan abbasi

12 Jul 2013 Rotate an image around a point Performs rotation of an image around any point inside of the image. jamesyu92

Works great for me.

24 Jun 2013 Bernsen local image thresholding Implementation of Bernsen's thresholding method. thong

05 Jun 2013 Bradley local image thresholding A fast an well performing local image thresholding method. Jan Motl

You can try to increase the size of the sliding window. Don't be afraid to increase the windows size to hundreds to hundreds pixels - the window should be bigger than the biggest symbol in the image.

Or you can try the post-processing step from Yanowitz and Bruckstein's binarization method: http://www.mathworks.com/matlabcentral/fileexchange/41786-remove-ghosts-from-binarized-images

Basically it looks at the edge of each foreground object. And if the average gradient along the edge is small, it concludes that it's false foreground object and deletes the object.

04 Jun 2013 Bradley local image thresholding A fast an well performing local image thresholding method. Max Neudecker

This method works quite well for binarizing my samples!
Note: I found that, depending on the grayvalue variations, a lot of background pixels are wrongly segmented as foreground. However, masking with another binary image, binarized e.g. with Otsu's threshold (function graythresh), remedied this.

02 Apr 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. bmv

I mean : B=magickernel(magickernel(A),'DOWN');

02 Apr 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. bmv

After these transformations:
A;
B=magickernel(magickernel(A),'DAWN');
Should A and B be the same? (A=B ?)

28 Feb 2013 Average Filter Average filter performs image smoothing with integral image method. Jan Motl

Hi Jan,
thank you for your feedback. The biggest gain from the vectorised version is in calculation of the integral image - cumsum accelerated the whole function by 5%. And that is good.

28 Feb 2013 Nadaraya-Watson smoothing A non-parametrical regression (smoothing) tool using Gaussian kernel. Jan Motl

Hi Mo,
I just uploaded a partially vectorised version, which should be a bit faster. Now the smoothing takes around 10 seconds to process 2500 samples on my computer. Let me know if you need it to be even faster.

25 Feb 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. Anton Semechko

The cambridgeincolour link is pretty awesome. Thanks!

25 Feb 2013 Nadaraya-Watson smoothing A non-parametrical regression (smoothing) tool using Gaussian kernel. Mo

Hi Jan,
Unfortunately, the calculation for more samples (for example 2500 samples) takes a very long time.
Isn't possible to make it faster?

24 Feb 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. Jan Motl

It's a trade-off. Either you can have sharp images with halos (that's the case of bicubic interpolation) or blurred images without halos (like with Magic kernel).

The artifacts particularly present in bicubic interpolation are described, for example, at Wikipedia: https://en.wikipedia.org/wiki/Bicubic_interpolation#Use_in_computer_graphics

Magic kernel is useful if you need extreme blow-ups or if you further post process the image and the used algorithm is sensitive to artifacts introduced by interpolation.

19 Feb 2013 Magic kernel resizing The “magic kernel” is a method of resampling images that gives clear results free of artifacts. Anton Semechko

So what are the artifacts that are present in the image interpolated with a cubic spline?

12 Feb 2013 Average Filter Average filter performs image smoothing with integral image method. Jan Simon

Although I like FOR loops, here a vectorized approach would be much more efficient, e.g.:
output = (t(1+m:rows+m, 1+n:columns+n) + t(1:rows, 1:columns) -
t(1+m:rows+m, 1:columns) - t(1:rows, 1+n:columns+n)) / winNum;

The documentation is very good: H1 line, exhaustive descritpion of inputs and outputs, "See also" line. I only miss a date and the author.
The inputs are check reliably.