Remove light reflection from the image
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Dear All;
I have an image for a transparent pipe but photo has a light reflection on the pipe section which makes white spot which affect affect my analysis, what is the best way to remove it ?
採用された回答
Image Analyst
2014 年 4 月 22 日
The usual way is to use crossed polarizers. Put one in front of the light source, and another one that rotates in front of the lens. Rotate the lens polarizer until the specular reflections is minimized. It's much better to prevent the problem in the first place like this than to try to repair a poor image.
13 件のコメント
mustafa alnasser
2014 年 4 月 23 日
Thank you However, i have no choice i took the image from another one and i have to deal with it . So, i need a way in matlab to reomve these white spots. i saw away to do that in mathematica by first identfying these white spots and then filter them , how can i do that? Best Regards
Image Analyst
2014 年 4 月 23 日
Please attach your image and tell me what you want to measure. Maybe the white can be ignored. I don't think you simply want to replace white pixels with black pixels - what good would that do? It's best just to make a mask that says essentially to just ignore the bad parts of your image.
Image Analyst
2014 年 4 月 25 日
mustafa's "Answer" moved here because it's not an answer:
Dear Image analyst;
Thank you for help
please check the following link, it has same issue that i want to do , he want to remove the light reflection from the apple, he did that in mathematica but i do not know how to do it in matlab. he first identify the white spots and remove them from the image , how can we do this in matlab
mustafa alnasser
2014 年 4 月 25 日
Dear Image analyst;
Thank you for help
please check the following link, it has same issue that i want to do , he want to remove the light reflection from the apple, he did that in mathematica but i do not know how to do it in matlab. he first identify the white spots and remove them from the image , how can we do this in matlab
Image Analyst
2014 年 4 月 25 日
mustafa, he did not "do" it as far as I can see. If you're not going to fix your image capture situation the best you can do is to create a mask to analyze around it, or to fill it in. If you want to fill it in, use my color segmentation routines in my file exchange to find "white" then dilate it one layer, then use roifill() to smear the surrounding colors into it, obliterating the white.
mustafa alnasser
2014 年 6 月 20 日
Dear Image Analyst;
Thank you for support .
To make the situation more clear for you , My image is attached and i want to remove this light reflection.
What do you suggest.
Regards
Image Analyst
2014 年 6 月 20 日
The image is not attached.
mustafa alnasser
2014 年 7 月 1 日
Dear Image Analyst;
I am able now to correct this . I have another problem now when i am trying to convert the image to Black and White and i have tried many adaptive threshold algorithms but none of them give me the correct answer. When i checked the histogram of the gray image , i found intensities level are distributed through the whole range from 0 - 255 . as you can see in the image , i want to make red area as white and other as black but i did not get the correct complete conversion using these algorithms even though by changing the tuning parameters.
What do you suggest.
Thanks in advance
Image Analyst
2014 年 7 月 1 日
How do I know what the "correct" answer should be? Maybe I'd try one of those algorithms that you already did and get a "wrong" answer just like you did.
To convert the red to white, convert the image to hsv with rgb2hsv.
hsv = rgb2hsv(rgbImage);
h = hsv(:,:,1);
s = hsv(:,:,2);
v = hsv(:,:,3);
Then extract the hue channel and threshold to find red, which will probably be around hue values of less than 0.1 and more than 0.9.
binaryImage = h < 0.1 | h > 0.9; % Adjust values as needed.
Then take that binary image you get from thresholding and set the value image to 1
v(binaryImage) = 1;
To set other areas to black (like you asked for), do this
v(~binaryImage) = 0;
Then convert back to rgb with hsv2rgb().
hsv = cat(3, h, s, v); % Use modified v to get new hsv.
rgbImage = hsv2rgb(hsv);
Image Analyst
2014 年 7 月 4 日
編集済み: Image Analyst
2014 年 7 月 4 日
mustafa's "Answer" moved here because it's not an "Answer" to the original question but actually a response to me:
Thank you very much for kind cooperation.
Your code works for this image to some extend but this not my goal. Let me explain it for you in more details:
Suppose that you have two liquids moving in pipe each one with a color , what i want to do it to convert the image to black and white image to calculate the area occupied by each of them. Using global threshold is not appropriate for such noisy image , so, adaptive threshold techniques are prefered for this type of images. I have tried about five algorthims but the conversion is not complete. For example, see the image , you can see that not all red area is converted to white especially at the edges where the red color is very light.
So, how can improve the situation ?
Best Regards


Image Analyst
2014 年 7 月 4 日
Looks like I did a pretty good job thresholding the hue channel. See attached test.m file below the screenshot. Be sure to change the folder name in the code to your folder and image name. I guess maybe you just needed to adjust your thresholds - can't tell because you didn't share your code.

mustafa alnasser
2014 年 7 月 12 日
Thank you very much for kind help. Indeed using HSV color model work very well for this kind of images.
I have run the code , it works well just a small thing , why the text and axis is flipped as shown in the attached image ? which MATLAB version do you use ?

Image Analyst
2014 年 7 月 12 日
This is a very strange result that I first saw about a month ago on one person's system. It was find for everyone else's. The fix was to change the renderer for the figure. I don't remember what fixed it but it was something like going from OpenGl to zbuffer or painter or something.
set(gcf, 'renderer', 'zbuffer');
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Image Segmentation についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
