Could MATLAB do text-mirroring?

9 ビュー (過去 30 日間)
JUNXIANG ZHANG
JUNXIANG ZHANG 2021 年 3 月 17 日
コメント済み: Walter Roberson 2021 年 3 月 17 日
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.

採用された回答

Walter Roberson
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
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
KSSV 2021 年 3 月 17 日
I = imread('image.png') ; % read image
I1 = fliplr(I) ; % flip the image
imshow(I1)
  2 件のコメント
JUNXIANG ZHANG
JUNXIANG ZHANG 2021 年 3 月 17 日
Thanks for the reply.
Problem is, it is only the text part that I wanna flip, instead of the entire image. A better example might be the following:
To:
Thanks again.
KSSV
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 ExchangeLanguage Support についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by