Main Content

Acquire Live Images in Color Thresholder

You can color threshold an image acquired from a webcam using the Color Thresholder app. The Image Capture tab enables you to bring a live image from USB webcams into the app.

To begin color thresholding, add images that you acquire live from a webcam using the MATLAB® Webcam support. Install the MATLAB Support Package for USB Webcams to use this feature. See Install the MATLAB Support Package for USB Webcams (Image Acquisition Toolbox) for information on installing the support package.

  1. Open the app using the colorThresholder function.

  2. To add a live image from your webcam, select Load Image > Acquire Image From Camera.

    Color Thresholder toolstrip with the Load Image dropdown showing three options to load images, including Acquire Image From Camera.

  3. The Import from Camera dialog box opens and displays camera properties and a live preview of the webcam. If you have only one webcam connected to your system, then it is selected by default. If you have multiple cameras connected and want to use a different one, select the camera in the Camera list.

    Image Capture tab showing a list of camera properties such as resolution and brightness, and a preview of the scene to be captured by the webcam.

  4. Use the sliders or drop-downs to change property settings. The list of camera properties varies, depending on your device. The live preview updates dynamically when you change a setting.

    After you adjust the camera settings, click Capture to capture a static image from the webcam. If you want to use this static image for color thresholding, then click Accept. Otherwise, you can click Retake to capture a new static image.

  5. The Choose a Color Space tab opens and displays the four color space options: RGB, HSV, YCbCr, and L*a*b*. Choose a color space by clicking the button of your choice.

    Image Capture tab showing the snapshot captured by the camera below four 3-D plots of the color values of the pixels in the different color spaces.

  6. The Color Thresholder app creates a new tab displaying the image and the color component controls for the selected color space. You can now perform color thresholding on the image. See Segment Image and Create Mask Using Color Thresholder for information about processing the image.

    RGB tab showing the snapshot captured by the camera to the left of three histograms that display the intensity of each color channel for the selected color space, RGB.

  7. If you want to save the image that you captured, click Export and select Export Images.

    Export To Workspace dialog box

    In the Export To Workspace dialog box, you can save the binary mask, segmented image, and the captured image. The Input RGB Image option saves the RGB image captured from the webcam.

See Also

Related Topics