shuffle image of tiles

조회 수: 4 (최근 30일)
dylan
dylan 2013년 10월 27일
편집: DGM 2022년 3월 27일
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

답변 (1개)

DGM
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.
If you just want something that works out of the box with any image, MIMT shuffle() works fine.
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
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
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!

Translated by