How to permute rows with specific number of permutation

3 ビュー (過去 30 日間)
sadiqa ilyas
sadiqa ilyas 2020 年 3 月 21 日
コメント済み: sadiqa ilyas 2020 年 3 月 21 日
Hi I want to permute the image first column wise then row wise with specific values. The code I have written gives correct answer with column permutation but gives an error for row permutation .
I1=imread('lina512.bmp');
I2=imresize(I1,[8 8]);figure;imshow(I2)
I=I2(:,:,1);figure;imshow(I)
csm = @(I,Col) circshift(I(:,Col),[3 1-Col]); % Arbitrary Matrix
callcsm = @(I) csm(I, 1:size(I,2));
HH1 = callcsm(I);
%row shift
csm = @(row,I) circshift(I(row,:),[1-row,3]); % Arbitrary Matrix
callcsm = @(I) csm(I, 1:size(I,2));
HH = callcsm(I);
error in row shift
index exceed matrix dimension

採用された回答

Sriram Tadavarty
Sriram Tadavarty 2020 年 3 月 21 日
Hi Sadiq,
In the row shift, the function handle csm takes in first input as row and next input as image I, but while accessing it in the function handle callcsm, you are sending first image I and then column indexes. Make the update here as stated and it will solve the issue.
csm = @(row,I) circshift(I(row,:),[1-row,3]); % Arbitrary Matrix
callcsm = @(I) csm(1:size(I,1),I); % Make the call to csm with proper signature as defined in csm
Hope this helps.
Regards,
Sriram
  1 件のコメント
sadiqa ilyas
sadiqa ilyas 2020 年 3 月 21 日
You r right thanks. can u plz tell me how to shift 3 or more elements bcz this only permutes one element .
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVehicle Network Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by