フィルターのクリア

How can I show 10 pixels width in all directions for an image?

1 回表示 (過去 30 日間)
Hadeel H
Hadeel H 2021 年 6 月 1 日
コメント済み: Hadeel H 2021 年 6 月 3 日
I am trying to find a block of the image, such as, the perimeter of the image, 10 pixels width in all directions. Can you please advise?
  2 件のコメント
darova
darova 2021 年 6 月 1 日
The question is unclear. Can you explain more? Show the image
Hadeel H
Hadeel H 2021 年 6 月 1 日
I have attached the image, I need to show 10 pixels width of the image

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 6 月 2 日
img = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/638445/download.jpg');
n = floor(size(img,2)/2);
leftb = imbinarize(rgb2gray(img(:,1:n,:)));
left = repmat(im2uint8(leftb), [1 1 size(img,3)]);
right = img(:,n+1:end,:);
newimg = [left,right];
imshow(newimg)

その他の回答 (1 件)

Adam Danz
Adam Danz 2021 年 6 月 1 日
編集済み: Adam Danz 2021 年 6 月 2 日
Clarified question in comment below:
> want to display the same image below but half colored and half binary!
Follow the steps in this blog.
figure();
tiledlayout(1,3,'Padding','none','TileSpacing','tight')
rgb = imread('download.jpg');
nexttile()
imshow(rgb);
title('Original image')
nexttile()
imshow(rgb);
I = rgb2gray(rgb);
hold on
h = imshow(I);
[M,N] = size(I);
halfway = round(N/2);
alpha_data = [ones(M,halfway),false(M,N-halfway)];
set(h, 'AlphaData', alpha_data);
title('Half grayscale')
nexttile()
imshow(rgb);
BW = imbinarize(I);
hold on
h = imshow(BW);
[M,N] = size(I);
halfway = round(N/2);
alpha_data = [ones(M,halfway),false(M,N-halfway)];
set(h, 'AlphaData', alpha_data);
title('Half binary')
  13 件のコメント
Adam Danz
Adam Danz 2021 年 6 月 2 日
Your comment above is clear. If that image was shared from the beginning, it would have save lots and time and back-and-forth Q&A.
But I still don't know what that has to do with your original question, "How can I show 10 pixels width in all directions for an image?"
Adam Danz
Adam Danz 2021 年 6 月 2 日
See updated answer.

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

カテゴリ

Help Center および File ExchangeRed についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by