
shuffle image of tiles
4 ビュー (過去 30 日間)
古いコメントを表示
Hi iam new to matlab, I have to write a function that will take in a image of any size, display it in square tiles and shuffles the squares around then show the new image
0 件のコメント
回答 (1 件)
DGM
2022 年 2 月 4 日
I know this is probably homework and there's no point in answering it, but it's a boring Friday.
The typical approach is probably to detile the image using mat2cell() and then randomly permute the cell array and then retile with cell2mat(). That's succinct and works so long as your image geometry is already integer-divisible by the number of tiles.
inpict = imread('peppers.png');
% note that [384 512] is not integer-divisible by [10 10]
tiling = [10 10];
outpict = shuffle(inpict,tiling); % output image is same size as inpict
imshow(outpict)

Default behavior is random permutation, but it can accept specified permutations as well.
2 件のコメント
Samia Nushrat
2022 年 3 月 26 日
Error using imtile>parse_inputs (line 242)
Expected input number 3, PARAM, to match one of these values:
'GridSize', 'Frames', 'ThumbnailSize', 'BorderSize', 'BackgroundColor'
The input, 'direction', did not match any of the valid values.
Error in imtile (line 151)
parse_inputs(varargin{:});
Error in shuffle (line 103)
outpict(:,:,:,f) = imtile(thisframe,tiles,'direction','col');
Error in Shuffle_mm (line 4)
outpict = shuffle(inpict,tiling); % output image is same size as inpict
Getting these errors, help please.
DGM
2022 年 3 月 27 日
編集済み: DGM
2022 年 3 月 27 日
The above example does not refer to the IPT function called imtile(). The two are completely different. IPT imtile() is more like montage(). MIMT imtile() and imdetile() are manipulation tools for 4D image arrays.
Since you're able to run other MIMT tools, I can only assume that MIMT has lower precedence in the path ordering than IPT does. You should be able to verify this by checking:
which imtile -all
You might ask why MIMT has a function with a name that conflicts with IPT. The answer is that it wasn't a conflict when I wrote it.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!