I am trying to compare two images to see the percentage difference in them. This is my code… NSImage *_imageNSImage1 = [[NSImage alloc]initWithContentsOfFile:@"/Users/len/Pictures/Debut/Check These/Untitled 00000004.png"]; NSSize _dimensions1 = [_imageNSImage1 size]; NSImage *_imageNSImage2 = [[NSImage alloc]initWithContentsOfFile:@"/Users/len/Pictures/Debut/Check These/Untitled 00000005.png"]; NSSize _dimensions2 = [_imageNSImage2 size]; self.image1ImageWell.image = _imageNSImage1; self.image2ImageWell.image = _imageNSImage2; NSLog(@"Width from CIImage: %f",_dimensions1.width); NSLog(@"Height from CIImage: %f",_dimensions1.height); NSLog(@"Width from CIImage: %f",_dimensions2.width); NSLog(@"Height from CIImage: %f",_dimensions2.height); if (_dimensions1.width != _dimensions2.width) { NSLog(@"Images are of different sizes"); return; } float diff = 0; for (int y = 0; y < _dimensions1.height; y++) { for (int x = 0; x < _dimensions1.width; x++) diff += fabs( GET_PIXEL(_imageNSImage1, x, y)[RED_C] - GET_PIXEL(_imageNSImage2, x, y)[RED_C] ) / 255.0; // ’NSimage’ does not have a member named ‘width’ diff += fabs( GET_PIXEL(_imageNSImage1, x, y)[GREEN_C] - GET_PIXEL(_imageNSImage2, x, y)[GREEN_C] ) / 255.0; // ’NSimage’ does not have a member named ‘width’ diff += fabs( GET_PIXEL(_imageNSImage1, x, y)[BLUE_C] - GET_PIXEL(_imageNSImage2, x, y)[BLUE_C] ) / 255.0; // ’NSimage’ does not have a member named ‘width’ } NSLog(@"diff: %f", 100 * diff / (_dimensions1.width * _dimensions1.height * 3)); The problem I am having is that ’NSimage’ does not have a member named ‘width’ in the last for loop as commented above. How can I modify my code to have it working? Thanks. Lennox
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)