Could MATLAB do text-mirroring?
조회 수: 10 (최근 30일)
이전 댓글 표시
Hi!
I would like to have some inserted text in an image mirrored. An example is shown by the figures below.
Original:
Wanted:
(Note that, this is no string flipping, like 'test' to 'tset')
And preferably NOT through the following work flow:
Cropping -> saving it as a new image -> loading -> flipping.
Much appreciated, thanks.
%% A better example would be:
Original:

Wanted:

The text was added with the function 'insertText'.
Thanks.
댓글 수: 0
채택된 답변
Walter Roberson
2021년 3월 17일
Your reference to cropping suggests that you want to do this to parts of images.
Remember that when you crop it is into an array. You can flip the array along the second dimension, and copy the result over the original array locations. There is no need to save to file.
Anything beyond that would be asking whether there is already a built-in function for this purpose. There is no built-in function for this.
Or perhaps you are asking for a built-in function that does ocr to locate text and flip it. There is no built-in function for that purpose.
Or perhaps you are asking for a built-in function that does ocr to locate text, determine what the size and font and symbols are, and synthesize new flipped characters. There is no built-in function for this purpose.
If you have a natural scene such as a photograph that has text overlay, and you want to flip the photograph but also locate and rectify the text so that after the flip of the entire photo, the text will again be readable... there is no built-in function for that. This is also a notably more difficult task, as it requires extrapolation of what was covered by the text to be able to restore the background before writing the new text on to it. For example the original text might happen to be hiding someone's face, and the flipped text might happen to have a space or hallow O in the position that should show the person's face now. This is a challenge to do, and probably requires Deep Learning to automate.
댓글 수: 1
Walter Roberson
2021년 3월 17일
"The text was added with the function 'insertText'."
In that case insertText into an array just large enough to hold the text, and fliplr the array, and then overwrite part of the image array with the flipped text.
추가 답변 (1개)
KSSV
2021년 3월 17일
I = imread('image.png') ; % read image
I1 = fliplr(I) ; % flip the image
imshow(I1)
댓글 수: 2
KSSV
2021년 3월 17일
편집: KSSV
2021년 3월 17일
Crop the text part of your image, when prompted.
I = imread('image.png') ;
[I1,rect] = imcrop(I) ; % crop the image where your text is present
%
I1 = fliplr(I1) ;
% Replace
position = round(rect) ;
col1 = position(1);
col2 = col1 + position(3)-1;
row1 = position(2);
row2 = row1 + position(4)-1;
I(row1:row2, col1:col2, :) = I1 ;

참고 항목
카테고리
Help Center 및 File Exchange에서 Language Support에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

