## patch #8059: [new function for image package] ranktf.m

 Submitted by: Ming Liu Submitted on: Sat 25 May 2013 06:18:15 AM UTC Category: None Priority: 5 - Normal Status: None Privacy: Public Assigned to: None Open/Closed: Open

Add a New Comment (Rich Markup):

## You are not logged in

Sun 26 May 2013 08:57:21 AM UTC, comment #4:

Actually rank transform is a good way of implementing "stereo matching" in computer vison. Because it ideally reduces the noise that is harmful to perform the stereo matching. In fact Matlab does not have a similar function. Here is a website for such kind of info:
http://siddhantahuja.wordpress.com/tag/rank-transform/
The author uses three for loops to achieve this.
Rank transform uses a sliding window algorithm, aims to find the rank of every pixel in its neighbors(4,9,16,25... neighbors,the square of 2,3,4,5...). This is why I used two for loops. Considering it is very slow, I am trying to vectorize it.
So take the window size 3 and an image with the size of 10*10 for example. I think:
1. Firstly I need to convert the image to a vector.
2. Then start at the item 1:3 and item 11:13 and item 21:23 as the first step. Try to find the rank of item 2 in all these items
3. ...
Is it a clear and a correct way to go? Or anyone has a better solution?

Ming Liu <liuming198904>
Sat 25 May 2013 04:40:10 PM UTC, comment #3:

Is there a matlab function that performs something similar to this so we can make it compatible? I don't find one.

Also, this function has 2 for loops to iterate over all pixels which will make it very slow. Could you vectorize it?

Carnë Draug <carandraug>
Sat 25 May 2013 06:29:42 AM UTC, comment #2:

example:

Irank = ranktf('test.png',9);
imshow(Irank)

Ming Liu <liuming198904>
Sat 25 May 2013 06:24:22 AM UTC, comment #1:

usage:

Irank = ranktf(image, window);
imshow(Irank,[]);

sorry, the 'windowsize' in the previous email is actually 'window', sorry for this typo

Ming Liu <liuming198904>
Sat 25 May 2013 06:18:15 AM UTC, original submission:

rank transform for an image.
image is the real name of an image. windowsize is the size of window to
be used for the rank transform, it must be an odd possitive integer number
greater than 3
I is the rank transformed image, based on the window size you choose.
For example, if the window size is 3x3 and apply
the window to the original grayscale image, then the center of the pixels
within the window from the original grayscale image will be
replaced by the ‘rank’ of the center pixel value. So it is between
1 and 9, assuming there are no same pixel values. The advantage is all the
pixel values in the image at last will be replaced by their ranks. So
the noise and other mistakes during taking the photo will be ideally
ignored. All the pixel values will be in a small range (the square of
the window size). This is a very useful function in image processing

Ming Liu <liuming198904>

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Comment:

Attached Files
file #28166:  Ming_Liu_ranktf.patch added by liuming198904 (2kB - application/octet-stream)
file #28167:  ranktf.m added by liuming198904 (2kB - application/octet-stream)

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -unavailable- added by liuming198904 (Submitted the item)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only logged-in users can vote.

Please enter the title of George Orwell's famous dystopian book (it's a date):