Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  Bitmap Image Filters
Subject:   confused by NSImage
Date:   2007-06-08 08:56:10
From:   barryrp
Hi


I need to produce an image filter on a mac. I've just acquired an intel mac complete with Xcode & am trying to learn cocoa asap (previous experience with VC & CodeWarrior). Came across this tutorial downloaded, converted to Xcode 2.4 and I'm a bit stuck! Some images seem to work - but then if you look closely repeated operations (you can Make Grayscale of a grayscale) move the image a pixel leftwards. I then created a TIFF - rectangle 200x100, all purple with white strip 10 pixels wide down righthand side. Tried this & the wihite band gets boken into strips & the resulting grayscale image has a black ban at the bottom. Looks as if each row is being shrunk. But stepping through the code all looks fine !
If you can reproduce this problem I would be very pleased (proves I'm not seeing things)!

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • confused by NSImage
    2009-03-16 03:37:52  Robin Forder [View]

    I can reproduce the problem, indeed. The explanation is, I believe, that the filter is set up to convert RGB to grayscale. If you try to convert grayscale to grayscale, each of the destination pixels will be an average of the corresponding source pixel, the pixel to the right of that one, and the pixel to the right of that. It would result in an average leftwards shift by one pixel. This explains the stepping to the left, probably the breaking up of your vertical band, and also the accompanying blurring.
    The first operation, rgb file to grayscale image, results in no leftwards move, which suggests that the effect is actually to do with the image formats.