开发者

displace an image vertically in matlab? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11开发者_运维问答 years ago.

This image is in gray scale, i´ve already done a scanning to detect the first and the last pixels i would like to move to top, and put those points into an array but all i´ve gotten is two pixels displaced.

I've found this example how to displace an image in python? , and it could help here but dont know how to make the changes


the example is very clear. It says that first you have to make a new matrix of the size you want your image to be. and then copy all of your pixel values into the new matrix. this is simple and good if you are not bothered about space.

if you want 'inplace' shift then you have to do the followig: I'll give an example and i hope you can take up from there: suppose your image matrix is something like this:

A(1:4,1:4) =

0 0 0 0
0 1 2 3
0 4 5 6

and you want to get:

1 2 3
4 5 6

then you can do:

A(1,:) = []; 
A(:,1) = [];

EDIT: taking the previous example, if you dont want to decrease the size of your matrix then you can copy the elements in the following way:

A(1,1) = A(2,2);
A(1,2) = A(2,3);
A(1,3) = A(2,4);

i think you can clearly see the pattern of copying. you can put the similar logic in a loop and that's it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜