Need help re: Lexicographic sorting on a Image

  • Follow


Hi, I am working on My ME project and need help re: Lexicographic sorting on an image, i need to read a image and then lexicographically sort the gray values and also store the index position , but i dont understand how it is to be done 

for eg.

Matrix

1      2       4       5     6

10    3       21     51     91

32    43     22    12      11 
 
45     33     11    23     55

87    44     22    88     99

what should be the output of the above matrix if i sort it lexicographically 
0
Reply Pallavi 12/15/2010 7:13:06 AM

Have you looked at the sort() and find() functions?  I think that
should do it.
0
Reply ImageAnalyst 12/15/2010 11:45:10 AM


Thanks 

But i am trying to use sortrows function in a loop startin with first column till nth and sort each column in ascending order but with order of the previous column

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <0c9b86ad-e8a0-4510-a578-571f44b03038@15g2000vbz.googlegroups.com>...
> Have you looked at the sort() and find() functions?  I think that
> should do it.
0
Reply Pallavi 12/15/2010 12:15:23 PM

Well explain what lexicographic sorting is, for a 2D matrix, first,
and then we can tell you how to achieve that.

Why do you want to do this anyway?  Is there a real-world need for
some reason, or is it just a mental puzzle/brainteaser.

What is an "ME project"?  Is that like a Masters of Science graduate
degree majoring in engineering or something?
0
Reply ImageAnalyst 12/15/2010 10:52:04 PM

I am doing Masters of Engineering in Computers , My project topic is Copy-move forgery Detection In which an Image is divided into blocks and then these blocks are converted to a array , then most of the research papers on copy-move states that after getting this array u need to lexicographically sort the elements which helps reduce the number of comparisons in the array

Eg.

Consider the following image


 1      2     3     4
5       6     7     8
11     55    1   2
45   1       5    6

Now i divide it into 2X2 Block

so i get the first block as  

1    2  
5    6   

2nd block as  

3  4 
7   8

and so on

Now i convert these blocks in to an array as

1     2      5    6
3     4      7     8  
11  55    45     1
1    2      5       6

Now i have to lexicographically sort the above array i dont know what does that mean?????????????





ImageAnalyst <imageanalyst@mailinator.com> wrote in message <889ff899-f0ad-48d1-bf01-980639396354@i18g2000yqn.googlegroups.com>...
> Well explain what lexicographic sorting is, for a 2D matrix, first,
> and then we can tell you how to achieve that.
> 
> Why do you want to do this anyway?  Is there a real-world need for
> some reason, or is it just a mental puzzle/brainteaser.
> 
> What is an "ME project"?  Is that like a Masters of Science graduate
> degree majoring in engineering or something?
0
Reply Pallavi 12/16/2010 5:51:05 AM

Can you explain how you got rows 3 and 4 of the output?  They seem to
have been reshaped into 1x4 blocks while the first two rows were 2x2
blocks.
0
Reply ImageAnalyst 12/16/2010 11:35:28 AM

 1       2        3          4 

 5      6         7          8

1       2         6          7

5       6         9           1


Now Convert this above matrix in to a array of size  4X4

where 1st row will have the elements from the first 2X2 Block

1      2       5      6
3      4       7      8
1      2       5      6
6      7       9      1

An array considering non overlapping blocks of size (2X2)

    
 
 


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <a6a2154e-cfb1-4fdb-8771-756aaba4aeeb@f8g2000yqd.googlegroups.com>...
> Can you explain how you got rows 3 and 4 of the output?  They seem to
> have been reshaped into 1x4 blocks while the first two rows were 2x2
> blocks.
0
Reply Pallavi 12/17/2010 6:48:04 AM

Well of course we can think of some code to handle this case (just as
I'm sure you can), but I'm not sure what elements go where for higher
dimensions.  Could you also give an example for a 6 by 6 matrix or a
10 by 10 matrix?
0
Reply ImageAnalyst 12/17/2010 11:15:36 AM

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <650a8138-e16c-4608-b391-d1e08ee7903b@v17g2000yqv.googlegroups.com>...
> Well of course we can think of some code to handle this case (just as
> I'm sure you can), but I'm not sure what elements go where for higher
> dimensions.  Could you also give an example for a 6 by 6 matrix or a
> 10 by 10 matrix?

Try this code... It is basically sorting the matrix entries in to lexicographically order.
%1  2  3  4
%5  6  7  8
%11 55 1  2
%45 1  5  6
index = 1;
A = [1 2 3 4;5 6 7 8;11 5 1 2;45 1 5 6]
B = zeros(4,4);
for i = 1:2:4
    for j = 1:2:4
        C = A(i:i+1,j:j+1)'
        reshape(C,1,4)
        B(index,:) = reshape(C,1,4)
        index = index +1;
    end
end
B
%1     2      5    6
%3     4      7    8  
%11    55     45   1
%1     2      5    6    
[B index] = sortrows(B)
%     1     2     5     6
%     1     2     5     6
%     3     4     7     8
%    11     5    45     1
0
Reply aliqureshi.ict (3) 11/9/2012 5:42:12 AM

8 Replies
512 Views

(page loaded in 0.127 seconds)

Similiar Articles:













7/23/2012 9:11:44 AM


Reply: